我不知道我在这里做错了什么,有人能看到我做错了什么吗?我只想将表单输入(在本例中为日期选择器)传递给 Controller 函数,但我尝试访问的所有内容都显示为未定义!
这是我的表格
<form ng-submit="showRefinedGameMarkers(refinements)">
<div class="list">
<div class="datepickers">
From Date:
<label class="item item-input">
<input ng-controller="DatepickerCtrl"
type="text"
placeholder="Pick date"
ng-model="refinements.from_datepicker"
name="from_datepicker"
ng-click="opendateModal()"
readonly>
</label>
</div>
这是我的 Controller 类
.controller('MapController', function($scope, $ionicLoading, gameFactory, $compile) {
$scope.showRefinedGameMarkers = function(refinements) {
$scope.refinements = refinements;
console.log($scope.refinements);
...
}
})
我尝试过的所有内容都显示为未定义,太烦人了!任何帮助将不胜感激,谢谢
最佳答案
您不需要将 refinements
传递给您的提交函数,因为它使用 ng-model 和 Angular 的绑定(bind)将为您更改 $scope.refinements
。
此外,您需要在 Controller 中初始化 refinements
变量。
$scope.refinements = {}
关于javascript - 表单提交时 Angular $scope 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28465330/