gpt4 book ai didi

javascript - 为什么 angular.bootstrap 代码不适用于 AngularJS V1.6 之前的版本?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:25:46 26 4
gpt4 key购买 nike

我的问题是,当我包含 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, use angular.element(callback) instead of angular.element(document).ready(callback))

— AngularJS angular.element API Reference

有关详细信息,请参阅,

关于javascript - 为什么 angular.bootstrap 代码不适用于 AngularJS V1.6 之前的版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44057395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com