Two dimensional array in table with unique ng model
1,604 views
Skip to first unread message
Don jose
unread,
Jun 14, 2016, 6:40:22 AM6/14/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AngularJS
i am having ng repeat in <tr> and <td> i am trying to achieve a time table like structure thus require unique ng model for each cell in table
here is my code
<trng-repeat="day in days track by $index"><td><inputng-disabled="true"class="form-control"ng-model="weekdays[$index]"></td>
<tdng-repeat="period in periods track by $index"><inputtype="text"ng-model="timetable.subject[[$parent.$index][$index]]"name="name"uib-typeahead="onesectionsubject as onesectionsubject.subjectMaster.subjectName+'/'+onesectionsubject.subjectTeacher.firstName for onesectionsubject in onesectionsubjects | filter:$viewValue | limitTo:8"class="form-control"pattern="[A-Za-z0-9 ]*"uib-tooltip="Enter valid subject name"tooltip-enable="form.name.$invalid"autocomplete="off"></td></tr>
Sander Elias
unread,
Jun 15, 2016, 2:23:10 AM6/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AngularJS
Hi Don,
It would be easier to help you when you demonstrator your issue in a plunk.
Probably you need to use ngInit in this case.
Regards
Sander
Don jose
unread,
Jun 15, 2016, 6:11:41 AM6/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
The $scope.timetable now holds an 2 dimensional array of the results that are put in the table.
Added an json output, so you can see what is in the array.
Is this what you where looking for?
Regards
Sander
Don jose
unread,
Jun 16, 2016, 1:13:32 AM6/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AngularJS
Thank you so much sir! This is what i am looking for!
Don jose
unread,
Jun 16, 2016, 1:21:40 AM6/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AngularJS
Sir,
Can you explain why ng init is used?
$parent.$index will not work??
Sander Elias
unread,
Jun 16, 2016, 1:26:53 AM6/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AngularJS
Hi Don,
Well, it will work, but its a bit to fragile in my opinion. If you insert another repeat, or do something else, it might mess up the $parent. Using ngInit, makes it explicit, and using a properly named variable makes its usage more clear, and as a result your template is easier to maintain.