Javascript 如何为Angular.js表单设置默认值和可更改值

Javascript 如何为Angular.js表单设置默认值和可更改值,javascript,forms,angularjs,Javascript,Forms,Angularjs,我已经设置了一个基本表单,通过angular.js进行绑定。当我没有默认设置时,选择和更改值显示和更新良好。我似乎不能做的是设置可以更改的默认值 我有一个用基本值定义的控制器(例如,一组带有默认值的单选按钮): 我的表格: <form action="#" method="post" ng-controller="Contact"> <input ng-model="contact.website" value=".com" id="com" type="radio" na

我已经设置了一个基本表单,通过angular.js进行绑定。当我没有默认设置时,选择和更改值显示和更新良好。我似乎不能做的是设置可以更改的默认值

我有一个用基本值定义的控制器(例如,一组带有默认值的单选按钮):

我的表格:

<form action="#" method="post" ng-controller="Contact">

 <input ng-model="contact.website" value=".com" id="com" type="radio" name="website">
 <label class="radio-label" for="com">website.com</label>

 <input ng-model="contact.website" value=".fr" id="fr" type="radio" name="website">
 <label class="radio-label" for="fr">website.fr</label>

 <input ng-model="contact.website" value=".br" id="br" type="radio" name="website">
 <label class="radio-label" for="br">website.br</label>
</form>

网站
网址:www.fr
网站。br
这在设置默认值时起作用。但是当我点击其他选项时,相应的
{{{contact.website}}
没有改变

我遗漏了什么?

我已经用你的例子构建了一个模型,并且似乎有效,除非我不理解你的问题

<div ng-app="app" >
<form action="#" method="post" ng-controller="Contact">

 <input ng-model="contact.website" value=".com" id="com" type="radio" name="website">
 <label class="radio-label" for="com">website.com</label>

 <input ng-model="contact.website" value=".fr" id="fr" type="radio" name="website">
 <label class="radio-label" for="fr">website.fr</label>

 <input ng-model="contact.website" value=".br" id="br" type="radio" name="website">
 <label class="radio-label" for="br">website.br</label>
     <p>{{contact.website}}</p>
</form>
</div>

网站
网址:www.fr
网站。br
{{contact.website}


看看这是不是你的意思…

你能举个例子吗?从你问题中的代码来看,它应该可以工作。我不能发布完整的代码作为它的工作。但这是essen@Akallebet的小提琴,它包含了它并起作用。我能看到的唯一区别是我没有定义一个特定的“应用程序”。我只是用,嗯。它在那里确实有效(这正是我想要的)。奇怪。我想知道我当时做了什么来打破它…我刚刚重建了这个,一切正常。我肯定在什么地方说了些奇怪的话。谢谢你确认我走在正确的道路上!
<div ng-app="app" >
<form action="#" method="post" ng-controller="Contact">

 <input ng-model="contact.website" value=".com" id="com" type="radio" name="website">
 <label class="radio-label" for="com">website.com</label>

 <input ng-model="contact.website" value=".fr" id="fr" type="radio" name="website">
 <label class="radio-label" for="fr">website.fr</label>

 <input ng-model="contact.website" value=".br" id="br" type="radio" name="website">
 <label class="radio-label" for="br">website.br</label>
     <p>{{contact.website}}</p>
</form>
</div>