angular.js - angularjs template loading problem in website development
大家讲道理
大家讲道理 2017-05-15 16:49:21
0
2
639

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

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
我想大声告诉你

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

    params['tx'] = '{{tx}}'
    return render_template('index.html', params = params)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template