angular.js - angular与服务器连接后失效
高洛峰
高洛峰 2017-05-15 16:50:22
0
1
684

我在本地试了一下angular的简单例子

myapp.js

var app = angular.module("myapp",[]);
app.controller("myctrl", function($scope){
    $scope.uplu = function(){
        $scope.su = $scope.lu;
    };

});
angular.bootstrap(document, ["myapp]);

这个是 angular代码

html

<html>
<head>
</head>
<body>
    <p ng-controller="myctrl">
        <p>请输入 字符</p>
        <input type="text" ng-model="lu">
        <button ng-click="uplu()">uplu</button>
        <p>{{su}}</p>
    </p>
<script src="http://cdn.staticfile.org/angular.js/1.3.0-beta.13/angular.min.js"></script>
<script src="myapp.js"></script>
</body>
</html>

这个在本地上是没有什么问题的, 可以运行出来 但是在服务器上运行angular就失效了(服务器也只是把页面渲染出来而已)

后台用的是 flask 只是简单渲染了一下页面,而且上面的模块都能加载的到而且不报错, 有没有人遇到过这样的问题啊。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
为情所困

It turns out that there is a conflict between the angular rendering template and the default jinja2 of flask. The solution is to add {% raw %}{% endraw %} to the static file so that jinja2 will not render the content or use {{" {{}}"}}Methods. The main thing is that jinja2 and angularde {{}} placeholders are the same

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!