Friday 15 August 2014

javascript - How to set default and changeable values for an Angular.js form -


I have a basic form, with binding along an angle. When I do not have any default set, then the value display selects and changes and the updates are updated. The default value is set which I can not seem to change.

I have a controller defined with basic values ​​(for example, a set of radio buttons with the default value):

  function contacts ($ radius) {$ Scope.contact = {'website': '.com'}};   

and my form:

  & lt; Form action = "#" method = "post" ng-controller = "contact" & gt; & Lt; Input ng-model = "contact.website" value = ".com" id = "com" type = "radio" name = "website" & gt; & Lt; = "Com" for label class = "radio-label" & gt; Website.com & lt; / Label & gt; & Lt; Input ng-model = "contact.website" value = ".fr" id = "fr" type = "radio" name = "website" & gt; & Lt; = "Fr" for label class = "radio-label" & gt; Website.fr & lt; / Label & gt; & Lt; Input ng-model = "contact.website" value = ".br" id = "br" type = "radio" name = "website" & gt; & Lt; = "Br" & gt; for label class = "radio-label" Website.br & lt; / Label & gt; & Lt; / Form & gt;   

Which works to set the default value but when I click on any other option, change the related {{contact.website}} does not do.

What am I missing?

I have created and worked with your example, as long as I understand your question Did not come in

  < Div ng-app = "app" & gt; & Lt; Form action = "#" method = "post" ng-controller = "contact" & gt; & Lt; Input ng-model = "contact.website" value = ".com" id = "com" type = "radio" name = "website" & gt; & Lt; = "Com" for label class = "radio-label" & gt; Website.com & lt; / Label & gt; & Lt; Input ng-model = "contact.website" value = ".fr" id = "fr" type = "radio" name = "website" & gt; & Lt; = "Fr" for label class = "radio-label" & gt; Website.fr & lt; / Label & gt; & Lt; Input ng-model = "contact.website" value = ".br" id = "br" type = "radio" name = "website" & gt; & Lt; = "Br" & gt; for label class = "radio-label" Website.br & lt; / Label & gt; & Lt; P & gt; {{Contact.website}} & lt; / P & gt; & Lt; / Form & gt; & Lt; / Div & gt;   

See what this means ...

No comments:

Post a Comment