【问题标题】:Checked checkbox from controller来自控制器的选中复选框
【发布时间】:2015-09-16 00:12:01
【问题描述】:

我有角度控制器

$scope.event = {
  },
  type: {
    checked : false
  }
};

我喜欢用它

<input id="show" name="type" type="checkbox" ng-model="event.type.checked">

当我重新加载页面时,我选中的复选框属性消失了。我该如何做条件,如果 event.type.checked == true,必须选中复选框,否则不选中。请帮忙

【问题讨论】:

  • $scope.event = { },输入:{检查:假}};里面有一个额外的大括号。

标签: angularjs checkbox


【解决方案1】:

查看演示:JSFiddle

这里有效:

angular.module('Joy', [])
    .controller('JoyCtrl', ['$scope', function ($scope) {
    $scope.event = {
        type: {
            checked: true
        }
    };
}]);

可能只是您的$scope.event 有一个额外的大括号。

【讨论】:

    【解决方案2】:

    不太确定,但此文档可能会对您有所帮助

    https://docs.angularjs.org/api/ng/directive/ngChecked

    【讨论】:

      猜你喜欢
      • 2011-05-08
      • 1970-01-01
      • 1970-01-01
      • 2012-11-18
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多