我有下面的AngularJS打開一個對話框,我輸入2個輸入字段並按ok()
將輸入的值寫入我的$scope
。AngularJS對象保持覆蓋並且不會被推動
這個工作,但是當我再次打開該模式,進入更多的細節到輸入欄,然後單擊ok()
我想這在我$scope
添加到當前input
對象,而是它只是過度寫它。
var theApp = angular.module('theApp', []);
var app = angular.module('theApp', ['ui.bootstrap']);
app.controller('MenuSideController', ['$scope','$modal','$log', function($scope, $modal, $log) {
var ModalInstanceCtrl;
$scope.createmarker = function() {
var modalInstance = $modal.open({
templateUrl: 'template/modal-add-marker.html',
controller: ModalInstanceCtrl,
resolve: {},
scope: $scope.$new()
});
modalInstance.result.then(function (selectedItem) {
}, function() {
$log.info('Modal dismissed at: ' + new Date());
});
};
ModalInstanceCtrl = function ($scope, $modalInstance) {
$scope.input = [];
$scope.ok = function() {
$modalInstance.close($scope.input);
console.log($scope);
$scope.gps = "";
$scope.title = "";
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
$scope.plotmarkers = function($scope) {
console.log($scope);
};
}]);
看看我在Plunker
請顯示什麼是我的$ scope中的'當前輸入對象?或更好的小提示/ Plunker後代碼示例 –
http://plnkr.co/edit/oYqDTtu4CaG5Htkj0jut?p=preview – ngplayground