Seven price
asked on
retrieve angularjs ID
<input type="text" ng-attr-id="{{ 'myid-' + q.ID }}" class="ng-pristine ng-untouched ng-valid" id="myid-1"><br />
<input type="text" ng-attr-id="{{ 'myid-' + q.ID }}" class="ng-pristine ng-untouched ng-valid" id="myid-2"><br />
<input type="text" ng-attr-id="{{ 'myid-' + q.ID }}" class="ng-pristine ng-untouched ng-valid" id="myid-3">
In angularjs in the js file how can I get the ID number only. exp... 1 , 2, 3
I don't understand the context for the question. Are you saying that you need a reference to the DOM element, and you want to get the "id" attribute value as "1" instead of "my-1"?
ASKER
here is a better example.
http://plnkr.co/edit/64uNN bIpIyiPoIq Mgfqs?p=pr eview
ok if you see I added a if statement but in the real world it does work.
if (item.QuestionID == item.QuestionIDs )
http://plnkr.co/edit/64uNN
ok if you see I added a if statement but in the real world it does work.
if (item.QuestionID == item.QuestionIDs )
ASKER
yes
I see this code, but I don't understand yet how it applies to this question. If you uncomment the if block, does it work, or do you get an error?
angular.forEach($scope.myData,function(item){
// if (item.QuestionID == item.QuestionIDs )
//{
question = $filter('filter')($scope.existingList, {
QuestionID: item.QuestionID
});
if(!item.answer && question.length>0){
item.answer = question[0].Response;
// }
}
})
ASKER
sorry, so frustrated with this. what I am trying to do is filter by comparing 2 values. Just so it can put the value in the text box. no luck.
If you are talking about this line, what is the problem with $filter expression?
question = $filter('filter')($scope.e xistingLis t, {
QuestionID: item.QuestionID
});
question = $filter('filter')($scope.e
QuestionID: item.QuestionID
});
ASKER
the filter is taking is taking the value with the foreach loop and for example if I have 456 it put it on line 4 , 5 and 6
or if I have id 30 it takes the value instead of putting it on line 30 it put it on row 3 and then row 30.
or if I have id 30 it takes the value instead of putting it on line 30 it put it on row 3 and then row 30.
ASKER
better example
http://plnkr.co/edit/JFSTs vNfvLDu5pc IpekU?p=pr eview
http://plnkr.co/edit/JFSTs
OK, I understand that, so now I am trying to understand your question in relation to the Plunker example.
ASKER
well i was going to lead to my question and try something by using the ID's to compare to the questionid. but if you know a better way please share.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tks