4

My problem is that when i include the URL:http://code.angularjs.org/snapshot/angular.js in the below <script> tag code works perfectly fine, instead if i use this URL: https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js, angular is not loaded/bootstrapped Why?

<!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>

My JS code in case it helps to resolve the problem:

angular.module('myApp', []);
angular.element(function() {
    angular.bootstrap(document, ['myApp']);
});
2

1 Answer 1

1

For AngularJS 1.6+ Use:

angular.module('myApp', []);
angular.element(function() {
    angular.bootstrap(document, ['myApp']);
});

For Older versions of AngularJS Use:

angular.module('myApp', []);
angular.element(document).ready(function() {
    angular.bootstrap(document, ['myApp']);
});

From the Docs:

  • ready() (deprecated, use angular.element(callback) instead of angular.element(document).ready(callback))

— AngularJS angular.element API Reference

For more information see,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.