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

In my angular controller i defined

$scope.flag1 = false;
$scope.flag2 = false;
$scope.flag3 = false;

I need to read those variable in my view page as bellow

<div flex="30" flex-sm="100" ng-repeat="shortListLoad in user.shortListLoads">
 <md-icon id = "{{'flag'+shortListLoad.id}}">
 </md-icon>
</div>

The thing is id ="{{'flag'+shortListLoad.id}}" brings as id = 'flag2' than id= 'false'.

how to get id= 'false' ? please help me?

share|improve this question
    
What does your user.shortListLoads look like? – Andre Kreienbring Nov 20 at 10:25

2 Answers 2

Another way is

<md-icon id = "flag{{id}}"> {{id}}</md-icon>

Working plunkr: http://plnkr.co/edit/1ufO3CJoUefVb2wDr4TZ?p=preview

share|improve this answer

If I understand your question right, you want to output to id flag1, or flag2 or flag3..

It's not recommended to use a function with angular binding, but you can do something like this.

$scope.getFlag = function(id){
    return 'flag'+id;
};

and in your view

 <div flex="30" flex-sm="100" ng-repeat="shortListLoad in user.shortListLoads">
     <md-icon id = "{{getFlag(shortListLoad.id)}}">
     </md-icon>
 </div>
share|improve this answer

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.