javascript - 如何在 Angular 中制作单选按钮

标签 javascript html angularjs user-interface radio-button

这是我的代码。当我提交 switchColors 时,服务器为其返回未定义。这是怎么错的?

另外,我应该如何在 Controller 中启动 $scope.swichColors ?目前我有 $scope.switchColors = '';

<label class="radio-inline">
    <input type="radio" ng-model="$parent.switchColors" value = "yes" >Yes</input>
</label>

<label class="radio-inline">
    <input type= "radio" ng-model = "$parent.switchColors" value = "no" >No</input>
</label>

最佳答案

尝试使用 ng-value 而不是 value

 <label class="radio-inline">
        <input type="radio" ng-model="$parent.switchColors" ng-value = "yes" >Yes</input>
    </label>

    <label class="radio-inline">
        <input type= "radio" ng-model = "$parent.switchColors" ng-value = "no" >No</input>
    </label>

关于javascript - 如何在 Angular 中制作单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36833895/

相关文章:

javascript - jQuery 将类添加到标签的子级以及所有标签的子级的子级

javascript - 为什么进度条与倒计时分开工作

html - 使用 float 和宽度的css div排列

javascript - 如何将一个数组的信息分割并发送到另一个数组?

javascript - Angular 嵌套 http 请求,以先前的请求作为参数

javascript - 优惠券验证

javascript - document.getElementById().value 返回空字符串而不是文本字段的值

javascript - 智能div,如果在屏幕左端则向右移动div,反之亦然

html - 具有宽度的常规段落下方的右浮动元素

html - 为水平对齐的按钮提供一个 Div 中的固定位置