javascript - angularJs取不到date-range-picker的ng-model值
问题描述
//日期控件
$scope.opts = {locale: { format: ’YYYY/MM/DD’, separator: ’ - ’, applyLabel: ’确定’, cancelLabel: ’取消’, weekLabel: ’W’, customRangeLabel: ’Custom Range’, daysOfWeek: moment.weekdaysMin(), min: ’’, max: ’’, monthNames: moment.monthsShort(), firstDay: moment.localeData().firstDayOfWeek()},eventHandlers: { ’apply.daterangepicker’: function (ev) {if ($scope.submitTime.startDate != ''){ $scope.query.BeginSubmitTime = sourceService.convertData($scope.submitTime.startDate._d); $scope.query.EndSubmitTime = sourceService.convertDataEnd($scope.submitTime.endDate._d);}if ($scope.modifyTime.startDate != '') { $scope.query.BeginCreatetime = sourceService.convertData($scope.modifyTime.startDate._d); $scope.query.EndCreatetime = sourceService.convertDataEnd($scope.modifyTime.endDate._d);}$scope.getProjectAuditPageList(); }} }
这个是js代码,代码是在同一个js中的;确定时间框之后是都能够进入这个方法里面的,只不过ng-include 中的时间框点击后取不到值,想问解决方案?
问题解答
回答1:你在外边定义一个对象比如obj,然后ng-model绑定一个ng-model='obj.submitTime'应该就可以了,原因可能是取不到的那个ng-model所在Scope实际上是外层可以取到的子Scope。
相关文章:
1. angular.js - angular 双向选框组件2. angular.js - 在用会话存储传递参数时,使用angularjs冲突3. angular.js - angular 引入 jweixin的问题4. angular.js - $emit(,)的具体意思是什么作用呢?5. jquery - angularjs的数据为什么渲染不到页面上?数据获取到了,我的代码哪里出了错了?6. node.js - 怎么在初始化的时候使得一个子组件不加载?7. angular.js - 请教angularjs里html和js通信的问题8. angular.js - 用angular2-cli打包项目之后,跳转路由刷新会报404的错误9. angular.js - angular post的Content-Type被设置,导致不能上传图片,求助!!10. angular.js - AngularJS v1.5.8 在IE9中出现灰屏,不启动的问题。