javascript - AngularJS - Binding radio button selection to model inside ng-repeat -
I have a data model person who takes the following form:
personsInfo = { Name: Adam Dub: 31-FB-198: Docs: [{DocType: Driver License, No: 121212, Selected: Wrong ID: 1}, {Selected: Truth, Doctor Type: None}, {Doctor Type: State ID, number: 132345, in my markup I have defined the following to generate radio buttons. & lt; Div ng- repeat = "person dock in person" Info.docs "> gt; input type =" radio "name =" personDocs "ng-model =" personDoc.selected "value =" "/> { {PersonDoc.docType}} & lt; span ng-hide = "personDoc.docType === 'none'" & gt; Number: {{persondoc.number}} & lt; / Div
I want to be able to check the documents that have been selected as correct on the page load, and then the flag chosen by the user is given to my people's Infodah Models In the case of saving it is to choose.
My intention here is to send the Infofuo model to another page.
If someone can tell me in a working Bella then he will be very appreciative!
Thanks!
You are not obliged to show which of the document you have chosen, we can choose an object to represent the selected object , Then wrap the form into that model.
JS
app.controller ('...', function ($ Scope) {$ scope.personInfo = {...}; $ Scope.selectedDoc = {}; $ Scope $ Watch ('personInfo', function () {$ scope.selectedDoc = $ scope.personInfo.Docs [0];});});
HTML
& lt; Div ng-repeat = 'person in the doctor Info.docs' & gt; & Lt; Input type = 'radio' ng-model = 'selected doc' value = 'doctor' / & gt; {{Doc.docType}} & lt; / Div & gt; & Lt; Form & gt; & Lt; Input type = 'text' ng-model = 'selectedDoc.number' / & gt; ... & lt; / Form & gt;
Comments
Post a Comment