Write static web pages with angularjs templateUrl
Just write the relative path of the template and load the template. However, in website development, due to security reasons, the relative path method cannot be used. How should I load the template at this time?
For example, in Flask, the template is placed in templates
, the static files are placed in static
, and my app.js
is placed in the static
folder. So far, there is no problem. When the template file needs to be loaded, no matter whether I write the template file in these two folders, templateUrl
will be reported when filling in the relative path. In js code, 404
cannot be used. How to solve this problem? url_for
My approach is to write an absolute path during development, which starts with /.
When deploying, use template compilation to compile all HTML template files into js, but the template identifier still starts with the original /, so there is no need to modify the file during development and deployment. It just adds another process of compiling templates.
http://github.com/jeremial/kman This is how it is handled in this project.
Templates for
falsk
模板引擎先于angularjs
渲染,现在我的做法是将angularjs
标签作为变量写进flask