I'm using a promise. But when my promise resolves the binding to the view doesn't bind to the new value.
I made a small jsfiddle: http://jsfiddle.net/58q8khap/8/
Here's the view:
<div ng-controller="MyCtrl">
Hello, {{name}}!
</div>
and the code:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope,ownservice) {
$scope.name = "Noname";
ownservice.getname().then(function(result){
$scope.name = 'Superhero';
});
}
myApp.service('ownservice', function ($q) {
this.getname = function () {
var deferred = $q.defer();
setTimeout(function() {
deferred.resolve('Superhero');
} , 1000);
return deferred.promise;
}
});