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

2

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,

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.