我正在尝试使用Angular UI Bootstrap Modal。我希望立即显示对模型的更改。
这是控制器:
$scope.testInputField = "";
$scope.showModal= function () {
var modalInstance = $modal.open({
templateUrl: 'partials/modal.html',
controller: 'ModalController',
resolve: {
inputTest: function () {
return $scope.testInputField;
}
}
});
modalInstance.result.then(function () {
// Do stuff
}, function () {
console.log("Some Error");
});
}
我的局部视图中也有testInputField模型。 这就是模态控制器
controller('ModalController', [ '$scope', '$modalInstance', 'inputTest', function ($scope, $modalInstance, inputTest) {
$scope.inputTest = angular.copy(inputTest);
$scope.keyPressed = function (key) {
$scope.inputTest+= key;
console.log($scope.inputTest);
};
} ])
所以基本上我想要的是每当使用keyPressed方法进行更改时,我的主控制器中的模态将同时更改。是否有可能使用UI引导模式当前代码
来实现此目的答案 0 :(得分:0)
对于此删除angular.copy方法,然后重试。因为它删除了对象的数据绑定。