0
我在使用angular-ui模式引用範圍時遇到了問題。我收到了關於範圍值的未定義消息。我想要做的是獲取將被輸入到ng-model =「input.cost_center」的數據。但是,當我改編其他人提供的關於同一主題的示例時,它似乎不起作用。有人可以幫助我嗎?在此先感謝使用angular-ui模式獲取未定義值的問題
這裏是普拉克http://plnkr.co/edit/tIh5rbvseD7vxfPJHFd6?p=preview
莫代爾
$scope.openAddCenter = function() {
var modalAddCenter = $modal.open({
templateUrl: 'myModalAddCenter.html',
controller: ModalAddCenterCtrl,
resolve: {
'$modalAddCenter': function() {
return function() {
return modalAddCenter; }
}
}
});
};
模態控制器
var ModalAddCenterCtrl = function ($scope, $modalAddCenter, $http){
$scope.input = {};
$scope.ok = function(){
alert($scope.input.cost_center);
$modalAddCenter().close();
};
$scope.cancel = function(){
$modalAddCenter().dismiss('cancel');
};
};
HTML
<input type="text" class="form-control" id="modalCenter" ng-model="input.cost_center" placeholder="Cost Center" ng-minLength="8" maxLength="8" required />
我仍然從ng-model =「input.cost_center」中獲取未定義的值,並且TypeError:object不是函數。這指出了$ scope.ok函數。 – MarkJ