Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ui路由器状态控制器在作用域中具有未定义的ng模型_Javascript_Angularjs_Angular Ui Router - Fatal编程技术网

Javascript ui路由器状态控制器在作用域中具有未定义的ng模型

Javascript 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.$

我试图通过一个注入了ui路由器的控制器来操纵一些输入数据,但我不清楚在这种情况下作用域应该如何工作

我附上我的示例场景:

模板html

<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问题。。多蠢的人啊