我在下面有一段代碼。如何將承諾值傳遞給函數
我需要傳遞一個值,我從它的代碼
這裏說**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:無法讀取屬性'項'的未定義' –