我在下面有一段代码。如何将承诺值传递给函数
我需要传递一个值,我从它的代码
这里说**value**
承诺得到低于
Auth.loggedInUser().then(function (user){
return user.id
});
下面我的承诺是角码
.run(['$rootScope', 'ngCart','ngCartItem', 'stores', function ($rootScope, ngCart, ngCartItem, stores) {
$rootScope.$on('ngShoppingCart:changed', function(){
ngCart.$save();
});
if (angular.isObject(stores.get(**value**))) {
ngCart.$restore(stores.get(**value**));
} else {
ngCart.init();
}
}])
如何我可以将异步函数中返回的值(值)传递给值的角码中吗?不确定适当的方法。
内得到它下面的作品,但对于这样的事情。这个空的= function(){ $ rootScope。$ broadcast('ngShoppingCart:change',{}); this。$ cart.items = []; Auth.loggedInUser(),然后(功能(用户){ $ window.localStorage.removeTheItem(user.id); })。 };' 我得到错误,如'TyppeError:无法读取属性'项'的未定义' –