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

Open in new window

In angularjs in the js file how can I get the ID number only.  exp... 1 , 2, 3
LVL 9
Seven priceFull StackAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
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"?
0
Seven priceFull StackAuthor Commented:
here is a better example.
http://plnkr.co/edit/64uNNbIpIyiPoIqMgfqs?p=preview

ok if you see I added a if statement but in the real world it does work.
if (item.QuestionID ==  item.QuestionIDs )
0
Seven priceFull StackAuthor Commented:
yes
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Bob LearnedCommented:
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;
      // } 
     }
    })

Open in new window

0
Seven priceFull StackAuthor Commented:
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.
0
Bob LearnedCommented:
If you are talking about this line, what is the problem with $filter expression?

 question = $filter('filter')($scope.existingList, {
      QuestionID: item.QuestionID
         });
0
Seven priceFull StackAuthor Commented:
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.
0
Seven priceFull StackAuthor Commented:
0
Bob LearnedCommented:
OK, I understand that, so now I am trying to understand your question in relation to the Plunker example.
0
Seven priceFull StackAuthor Commented:
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.
0
Ioannis ParaskevopoulosCommented:
Hi,

I think you may use the third option of the $filter expression and use a function. So instead of:

question = $filter('filter')($scope.existingList, {QuestionID: item.QuestionID});

Open in new window


You could use:

question = $filter('filter')($scope.existingList,  function(value) {
    return value.QuestionID === item.QuestionID;
});

Open in new window


Check out the edited plunker.

Giannis
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Seven priceFull StackAuthor Commented:
tks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.