Previously, my code works fine in AngularJs 1.1.5 version, but after upgrade to 1.2.x, the following codes don't work. Are there anything changed in 1.2.x?
Here is the demo: http://plnkr.co/edit/w2O8Ci It cannot show the "world", but if you change the angularjs back to 1.1.5, everything's working fine.
Here is the code:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<!--<script src="http://code.angularjs.org/1.1.5/angular.min.js"></script>-->
<script src="http://code.angularjs.org/1.2.9/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
app.factory('NameFactory', function($http, $q) {
return {
getName: function() {
var deferred = $q.defer();
deferred.resolve({
name: "World"
});
return deferred.promise;
}
}
});
app.controller("NameCtrl", function($scope, NameFactory) {
$scope.name = NameFactory.getName();
});
</script>
</head>
<body ng-controller="NameCtrl">
<h1>Hello, {{name.name}}</h1>
</body>
</html>