ng-model 是 AngularJS 中的一个重要属性,表示数据的双向绑定。
但是当其作用在复选框中时,与其他可输入文本的表单又稍有区别。

复选框中的 ng-model ,其值只有 truefalse
不用想,就知道代表的是『是否选中』的意思。

比如,页面初始化时,我在controller中定义如下:

$scope.plan = {
    lastYear:false,
    custom:true
};

而页面方面:

<div class="col-md-12">
    <div class="form-inline">
        <input type="checkbox" >
        <label for="lastYear" ng-click="clickLastYear()">根据上一年xxx生成公区预算明细</label>
    </div>
    <div class="form-inline">
        <input type="checkbox" >
        <label for="custom" ng-click="clickContent()">自定义</label>
    </div>
</div>

那么其效果:

AngularJS中复选框(checkbox)的ng-model

更详细的资料:
AngularJs checkbox绑定
Angularjs checkbox的ng属性

相关文章:

  • 2021-12-26
  • 2021-10-25
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2022-01-11
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案