How to get all the same ngModels dynamically and put them into an array

21 views
Skip to first unread message

Erichain Zain

unread,
Mar 28, 2016, 11:05:59 AM3/28/16
to AngularJS
Version of Angular: 1.3.0

Platform: Mac OS X 10.11

I have mutiple ngModels in my page that are the same. And I would add one by one dynamically.

So, how can I get all the same ngModels and put them into an array ?

Here is a pen to show my question:

Sander Elias

unread,
Mar 29, 2016, 6:04:04 AM3/29/16
to AngularJS
Hi Erichain,

You are making it way more complex as it needs to be. In angular, the DOM follows the data. If you have the need to read data back out of the DOM, you probably doing something that can be solved easier or more efficient. 
I took your pen, and worked it around so it used an more "angular" way of working. 

I hope this helps you a bit,
Regards
Sander

Erichain

unread,
Mar 29, 2016, 6:30:21 AM3/29/16
to ang...@googlegroups.com
Hi, Sander, thank you very much. I have been troubled by this problem for a long time. Your solution helps me a lot ! It works !
-------------------
Erichain
-------------------

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/ObW4ar0YUms/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages