1

谁知道为什么它不起作用?

我想在单选按钮上使用 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> 
4

1 回答 1

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

不仅

知识关于用户

于 2014-07-11T11:15:41.570 回答