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
我想大声告诉你2017-05-15 16:51:21
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.
巴扎黑2017-05-15 16:51:21
Templates for
falsk
模板引擎先于angularjs
渲染,现在我的做法是将angularjs
标签作为变量写进flask
params['tx'] = '{{tx}}'
return render_template('index.html', params = params)