相关疑难解决方法(0)

复选框未绑定到angularjs中的范围

我正在尝试使用ng-model将复选框绑定到范围.复选框的初始状态对应于范围模型就好了,但是当我选中/取消选中复选框时,模型不会更改.需要注意的一些事项是模板是在运行时使用ng-include动态加载的

app.controller "OrdersController", ($scope, $http, $location, $state, $stateParams, Order) ->

  $scope.billing_is_shipping = false
  $scope.bind_billing_to_shipping = ->
    console.log $scope.billing_is_shipping


<input type="checkbox" ng-model="billing_is_shipping"/>
Run Code Online (Sandbox Code Playgroud)

当我选中该框时,控制台会记录错误,当我取消选中该框时,控制台会再次记录错误.我也在范围上有一个订单模型,如果我将复选框的模型更改为order.billing_is_shipping,它工作正常

checkbox binding coffeescript angularjs angularjs-ng-include

58
推荐指数
4
解决办法
5万
查看次数