Checkbox not binding to scope in angularjs

前端 未结 4 957
旧时难觅i
旧时难觅i 2020-12-01 01:34

I am trying to bind a checkbox to scope using ng-model. The checkbox\'s initial state corresponds to the scope model just fine, but when I check/uncheck the checkbox, the m

4条回答
  •  囚心锁ツ
    2020-12-01 02:34

    If the template is loaded using ng-include, you need to use $parent to access the model defined in the parent scope since ng-include if you want to update by clicking on the checkbox.

    function Ctrl($scope) { $scope.billing_is_shipping = true; $scope.checked = function(){ console.log($scope.billing_is_shipping); } }

    DEMO

提交回复
热议问题