<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{firstName + " " + lastName}}
{{obj}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope ,$q,$timeout) {
$scope.firstName = "John";
$scope.lastName = "Doe";
var pro=function(){
var a=$q.defer();
$timeout(function(){
console.log("resolve");
a.resolve(1);
},
3000
);
return a.promise;
}
$scope.obj=pro();
});
</script>
As i study when we use promise object in view it automatically adds resolve function to show the resolve value in view but it is not showing resolved value in view.it is just showing this "{}".what is wrong i am doing
$parse
and templates in general will no longer automatically unwrap promises.
For more information, see
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.