谁知道为什么它不起作用?
我想在单选按钮上使用ngModel设置$ rootScope值。
这是一个例子jsFiddle
<form name="pageTwoForm">
<h3>General Information > Knowledge About </h3>
<div>
<b>User</b>
<div ng-repeat="option in userOptions">
<input type="radio" ng-model="knowledgeAboutUser" ng-value="option.id" />{{option.text}}
</div>
<b>Target Group</b>
<div ng-repeat="option in targetGroupUserOptions">
<input type="radio" ng-model="$parent.knowledgeAboutTargetGroup" ng-value="option.id" />
{{option.text}}
</div>
</div>
</form>
<h3 >{{knowledgeAboutTargetGroup}}</h3>
<h3 >{{knowledgeAboutUser}}</h3>
答案 0 :(得分:3)
我解决了它
<form name="pageTwoForm">
<h3>General Information > Knowledge About </h3>
<div>
<b>User</b>
<div ng-repeat="option in userOptions">
<input type="radio" ng-model="data.knowledgeAboutUser" ng-value="option.id" />{{option.text}}
</div>
<b>Target Group</b>
<div ng-repeat="option in targetGroupUserOptions">
<input type="radio" ng-model="data.knowledgeAboutTargetGroup" ng-value="option.id" />
{{option.text}}
</div>
</div>
</form>
<h3 >{{data.knowledgeAboutTargetGroup}}</h3>
<h3 >{{data.knowledgeAboutUser}}</h3>
我不知道为什么但如果我使用
它会起作用data.knowledgeAboutUser
不仅
knowledgeAboutUser