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']);
});
georgeawg
  • 48,608
  • 13
  • 72
  • 95
Dheemanth Bhat
  • 4,269
  • 2
  • 21
  • 40
  • URL:http://code.angularjs.org/snapshot/angular.js is from the example code on angular bootstrapping from the AngularJS official website. – Dheemanth Bhat May 18 '17 at 20:56
  • `snapshot` is the latest beta build (v1.6.5-build.5390+sha.a86a319). It is better to use the latest stable release: https://unpkg.com/angular@1.6.4/angular.js – georgeawg May 18 '17 at 23:40

1 Answers1

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,

Community
  • 1
  • 1
georgeawg
  • 48,608
  • 13
  • 72
  • 95