angular.js - angular fails after connecting to the server
高洛峰
高洛峰 2017-05-15 16:50:22
0
1
727

I tried a simple example of angular locally

myapp.js

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

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

This is angular code

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>

There is no problem with this locally and it can be run. However, it fails when running angular on the server (the server only renders the page)

The backend uses flask and simply renders the page, and the above modules can be loaded without error. Has anyone encountered such a problem?

高洛峰
高洛峰

拥有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