Join the Stack Overflow Community
Stack Overflow is a community of 6.8 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

i have used material design class in my app.

<div flex="30" flex-sm="100" ng-repeat="shortListLoad in user.shortListLoads">
 <md-button class="md-icon-button md-primary" aria-label="Settings" ng-click="checkShortList(shortListLoad.id)">
   <md-icon md-font-icon='icon-favorite' style='color:red'></md-icon>
 </md-button>
</div>

I need to change the "md-font-icon" attribute value to 'icon-favorite-outline' while calling the checkShortList() function in controller.

How to do this please suggest a best way in angularjs rather than jquery???

share|improve this question
    
you mean on click of button change attr value – ngLover Nov 20 '15 at 8:27
    
yes bro it'l be handle in controller – user3391137 Nov 20 '15 at 8:35
up vote 1 down vote accepted

Set flag value in your controller method checkShortList. Keep a flag in each of the shortListLoad object.

//initially
 angular.forEach(user.shortListLoads,function(res){
    res.flag = true;
 }); 

 $scope.checkShortList = function(shortListLoad,id){
     shortListLoad.flag = false;
 }

HTML

    <md-button class="md-icon-button md-primary" aria-label="Settings" ng-click="checkShortList(shortListLoad,shortListLoad.id)">
         <md-icon md-font-icon="{{shortListLoad.flag ? 'icon-favorite' : 'icon-favorite-outline'  }}" style='color:red'></md-icon>
</md-button>
share|improve this answer
    
Please see the edited one, it's under "ng-repeat" how to change specific one? – user3391137 Nov 20 '15 at 9:02
    
check edited one – ngLover Nov 20 '15 at 9:07
    
$scope.flag = true; //initially it's not take as initial value. flag initial value is false while loading the page – user3391137 Nov 20 '15 at 9:22
    
did you get my question?? – user3391137 Nov 20 '15 at 9:30
    
i got that check edited one and try to figure out – ngLover Nov 20 '15 at 10:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.