我有一個組件,我正嘗試構建,它接受user_id
,然後在後臺加載用戶信息,然後使用另一個指令附加到該頁面上的元素。範圍屬性更新時的指令模板更新
到目前爲止,這是我
<user-popover user-id="item.item_high_bid_user_id"></user-popover>
angular.module('bidrAdminApp')
.directive('userPopover', ['Data', function (Data) {
return {
template: '<a bb-popover-template="user-popover-content.html">{{user.user_name}}</a><i ng-hide="{{user}}" class="fa fa-spinner fa-spin" aria-hidden="true"></i>',
scope: {
userId: '=',
user: '=*'
},
restrict: 'E',
controller: function($scope, $element, $attrs, Data){
Data.getUser($scope.userId).then(function(userData){
$scope.user = userData.data;
});
},
};
}]);
我得到的數據加載從我Data
服務的背景和在模板中user.user_name
得到正確更新,問題是微調不被隱藏當$scope.user
得到更新時。一旦加載了用戶數據並更新了模板的其餘部分,我怎麼才能讓微調器隱藏起來。
UPDATE
我要在這裏說這些指令中的項目重複網格顯示何況,該指令的目的是,當你將鼠標懸停在某人有點像一個用戶將鼠標懸停卡,與Facebook類似並且你得到了一個關於用戶信息的popover,所以我真的很希望這個指令的每個迭代都能夠獨立運行,因爲現在加載指示器在所有指令完成加載它們的屬性後隱藏。
剛落「用戶名:‘= *’」部分在你的指令範圍,應該是很好,我猜。 – Gatsbill
@Gatsbill如果我刪除了這個,spinner仍然會保留。 – Jordan