我的问题是,当我包含 URL 时:http://code.angularjs.org/snapshot/angular.js
在下面<script>
标签代码工作得很好,
相反,如果我使用此 URL:https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js , angular 没有加载/引导 为什么?
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script type="text/javascript" src="Program6.js"></script>
</head>
<body>
<div>
<input type="text" ng-model="sampledata" />
<p>{{ sampledata }}</p>
</div>
</body>
</html>
我的 JS 代码以防它有助于解决问题:
angular.module('myApp', []);
angular.element(function() {
angular.bootstrap(document, ['myApp']);
});
最佳答案
对于 AngularJS 1.6+ 使用:
angular.module('myApp', []);
angular.element(function() {
angular.bootstrap(document, ['myApp']);
});
对于旧版本的 AngularJS 使用:
angular.module('myApp', []);
angular.element(document).ready(function() {
angular.bootstrap(document, ['myApp']);
});
来自文档:
ready()
(deprecated, useangular.element(callback)
instead ofangular.element(document).ready(callback)
)
有关详细信息,请参阅,
关于javascript - 为什么 angular.bootstrap 代码不适用于 AngularJS V1.6 之前的版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44057395/