admin 管理员组文章数量: 1086019
Problem:
I started using angular.js for my project and during development I noticed that controller sometimes doesn't load, so I tried removing parts of the project until the smallest possible example but the problem still remains.
Code:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body ng-app="myApp">
<div ng-controller="TestController">
<input ng-model="testText" type="text" placeholder="Enter text">
</div>
<script src="/static/js/angular.js"></script>
<script src="/static/js/app.js"></script>
</body>
</html>
app.js
console.log("INIT");
angular.module('myApp', [])
.controller('TestController', ['$scope', function($scope) {
$scope.testText = '172.17.2.1';
console.log("SCOPE");
}]);
Note:
"INIT" part always gets displayed in console. Altough "SCOPE" part sometimes (or most of the time) doesn't so the input field doesn't get filled.
Versions:
Chrome: 36.0.1985.125
Angular.js: 1.3.14
Problem:
I started using angular.js for my project and during development I noticed that controller sometimes doesn't load, so I tried removing parts of the project until the smallest possible example but the problem still remains.
Code:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body ng-app="myApp">
<div ng-controller="TestController">
<input ng-model="testText" type="text" placeholder="Enter text">
</div>
<script src="/static/js/angular.js"></script>
<script src="/static/js/app.js"></script>
</body>
</html>
app.js
console.log("INIT");
angular.module('myApp', [])
.controller('TestController', ['$scope', function($scope) {
$scope.testText = '172.17.2.1';
console.log("SCOPE");
}]);
Note:
"INIT" part always gets displayed in console. Altough "SCOPE" part sometimes (or most of the time) doesn't so the input field doesn't get filled.
Versions:
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Mar 1, 2015 at 20:14 OndrajZOndrajZ 4674 silver badges19 bronze badges 2Chrome: 36.0.1985.125
Angular.js: 1.3.14
- Seems to be working fine here: jsfiddle/g33ct2ah Are there no errors in the console? – JLRishe Commented Mar 1, 2015 at 20:19
- No, there are no errors in javascript console. – OndrajZ Commented Mar 1, 2015 at 20:23
1 Answer
Reset to default 14Problem was "AngularJS Batarang" extension for Chrome. It was somehow messing up with the angular. I never actually used it, installed it sometime ago when researching angular.js and forgot it enabled.
I disabled it and everything works fine.
本文标签: javascriptSimple angularjs example sometimes doesn39t loadStack Overflow
版权声明:本文标题:javascript - Simple angular.js example sometimes doesn't load - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744031045a2521502.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论