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'應(yīng)該就可以了,原因可能是取不到的那個ng-model所在Scope實際上是外層可以取到的子Scope。
相關(guān)文章:
1. Span標(biāo)簽2. docker-machine添加一個已有的docker主機問題3. redis啟動有問題?4. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””5. angular.js使用$resource服務(wù)把數(shù)據(jù)存入mongodb的問題。6. javascript - 計算面積函數(shù)代碼7. javascript - ng-options 設(shè)置默認(rèn)選項,不是設(shè)置第一個哦,看清楚了!8. SessionNotFoundException:會話ID為null。調(diào)用quit()后使用WebDriver嗎?(硒)9. java - Spring MVC無法識別Controller導(dǎo)致返回的結(jié)果是404?10. java - Collections類里的swap函數(shù),源碼為什么要新定義一個final的List型變量l指向傳入的list?
