加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 08:54:24 所属栏目:安全 来源:网络整理
导读:我试图使用ng-model绑定一个复选框到scope。复选框的初始状态对应于范围模型很好,但是当我选中/取消选中复选框时,模型不会改变。需要注意的是,模板是在运行时使用ng-include动态加载的 app.controller "OrdersController",($scope,$http,$location,$state
我试图使用ng-model绑定一个复选框到scope。复选框的初始状态对应于范围模型很好,但是当我选中/取消选中复选框时,模型不会改变。需要注意的是,模板是在运行时使用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"/>

当我选中框控制台日志为false,当我取消选中该框,控制台再次日志为false。我也有范围的订单模型,如果我改变复选框的模型为order.billing_is_shipping,它工作正常

我努力解决这个问题一段时间。什么工作是将输入绑定到对象而不是基元。
<!-- Partial -->
<input type="checkbox" ng-model="someObject.someProperty"> Check Me!

// Controller
$scope.someObject.someProperty = false

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读