javascript - AngularJS ng-repeat track by not selecting initial value -


Still new to angular, please bear with me. I have a radio button list that I generate using NG-Repeat I am storing the selected object in a different variable on the same controller.

Setting one of the objects in the selected object list with a different example. I thought that since the ID is identical, that using the expression "by track" will select the right item in the list, but it is not. If I select a radio button, then it will update the selected variable as expected.

Am I doing something wrong? Is this a bad pattern?

  & lt; Form name = "myForm" ng-controller = "MyCtrl" & gt; & Lt; Label ng-repeat = "person tracked by person." & Gt; & Lt; Input type = "radio" ng-model = "$ parent.selected" ng-value = "person" /> {{Person.name}} & lt; / Label & gt; & Lt; / Form & gt;   

Here's my controller:

  Angular.module ('ngapdam', []). Controller ('microtation', microlton) function muqtula ($ scope)) {$ Scope.selected = {id: 2, name: "paul"}; {Id: 4, name: "$"}, {id: 1, name: "John"}, {id: 2, name: "Paul"}, {id: 3, name: "George"} Frank "} ];}   

This is my

Update:
I recognize the fact that if I'm from an archive of an object However, it is not like this that I am currently setting up. For example, I am using "selected" for coming from a different function and given as follows Is not generated from the list. < P>

And it is now fixed:

You only select something in the list It does not compare to the context of the value.

  MyCtrl ($ scope) {$ scope.people = {{ID: 1, name: "John"} , {Id: 2, name: "Paul"}, {id: 3, name: "George"}, {id: 4, name: "frank"}] $ $ scope.fixed = $ scope.Pages [ 1];}   

Update All you have to do is just mail yourself to match on the ID Is the one to write routines that the other functions that it is able to produce its own object and finds the same object in your $ sector. For example the list of people:

  find function selected psearchan (selected) {for (var i = 0; i & lt; $ scope.people.length; i ++) { If ($ scope.people [i] .id == selected.id) $ scope back People [i]; } Return tap; }   

This will fix it.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -