问题:
我开始在我的项目中使用angular.js,在开发过程中我注意到控制器有时无法加载,所以我尝试删除项目的一部分,直到尽可能小的例子,但问题仍然存在。
代码:
的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");
}]);
注意:
“INIT”部分始终显示在控制台中。有时(或大部分时间)Altough“SCOPE”部分不会使输入字段无法填充。
版本:
Chrome:36.0.1985.125
Angular.js:1.3.14
答案 0 :(得分:15)
问题是Chrome的“AngularJS Batarang”扩展程序。它以某种方式弄乱了角度。我从来没有真正使用它,在研究angular.js之前安装它并忘记启用它。
我禁用了它,一切正常。