0

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???

2
  • you mean on click of button change attr value Commented Nov 20, 2015 at 8:27
  • yes bro it'l be handle in controller Commented Nov 20, 2015 at 8:35

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

7 Comments

Please see the edited one, it's under "ng-repeat" how to change specific one?
$scope.flag = true; //initially it's not take as initial value. flag initial value is false while loading the page
did you get my question??
yes man it's working ... can you say when this angular.forEach() method is calling? it's while page loading?
just put it as it is in your controller
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.