Javascript ui路由器状态控制器在作用域中具有未定义的ng模型
我试图通过一个注入了ui路由器的控制器来操纵一些输入数据,但我不清楚在这种情况下作用域应该如何工作 我附上我的示例场景: 模板htmlJavascript ui路由器状态控制器在作用域中具有未定义的ng模型,javascript,angularjs,angular-ui-router,Javascript,Angularjs,Angular Ui Router,我试图通过一个注入了ui路由器的控制器来操纵一些输入数据,但我不清楚在这种情况下作用域应该如何工作 我附上我的示例场景: 模板html <div class="date-filter-gallery"> <input type="date" ng-model="date.start"> <input type="date" ng-model="date.end"> </div> 控制器 StationGalleryController.$
<div class="date-filter-gallery">
<input type="date" ng-model="date.start">
<input type="date" ng-model="date.end">
</div>
控制器
StationGalleryController.$inject = ['$scope'];
function StationGalleryController($scope) {
let sg = this;
$scope.date.start = new Date(2017,1,1);
$scope.date.end = new Date(2017,2,1);
}
$scope.date未定义
我为这个问题道歉,但我对这个棱角分明的世界还不熟悉
谢谢首先实例化
$scope.date
对象。例如:
$scope.date = {};
$scope.date.start = new Date(2017,1,1);
$scope.date.end = new Date(2017,2,1);
或者,如果您愿意:
$scope.date = {
'start': new Date(2017,1,1),
'end': new Date(2017,2,1)
}
首先实例化
$scope.date
对象。例如:
$scope.date = {};
$scope.date.start = new Date(2017,1,1);
$scope.date.end = new Date(2017,2,1);
或者,如果您愿意:
$scope.date = {
'start': new Date(2017,1,1),
'end': new Date(2017,2,1)
}
tnx,所以基本的js问题。。多么愚蠢:Dtnx,那么基本的js问题。。多蠢的人啊