I have a component I'm trying to build that accepts a user_id
and then loads user information for it in the background, and then drops an element on the page with another directive attached to it.
So far this is what I have
<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;
});
},
};
}]);
I'm getting data loading in the background from my Data
service and the user.user_name
in the template gets updated correctly, the issue is the spinner is not being hidden when the $scope.user
gets updated. How can I get the spinner to hide once the user data has been loaded in and the rest of the template has been updated.
UPDATE
I need to mention here that these directives show up in a repeating grid of items, this directive is intended to act sort of like a user hover card, similar to facebook when you hover over someone and you get a popover with some information about the user, so I would really like each iteration of this directive be able to stand on its own, as it stands now the loading indicator hides after all the directives have finished loading their $scope.user
property.