【问题标题】:UI angular modal controller $scope values handling mistakeUI角度模态控制器$scope值处理错误
【发布时间】:2014-05-01 03:24:45
【问题描述】:
【问题讨论】:
标签:
javascript
angularjs
modal-dialog
angular-ui-bootstrap
【解决方案1】:
模态窗口有自己的范围。你要做的就是把你的模型变成一个对象。所以把bootusername命名为bootusername.text
然后您可以在实例控制器中初始化bootusername 并像这样设置模型:
var ModalInstanceCtrl = function ($scope, $modalInstance)
{
$scope.bootusername = {}; //initialize the object
$scope.check1 = function()
{
$scope.bootusername.text = 56; //set the object here or just type in input
};
$scope.check2 = function()
{
console.log($scope.bootusername.text);
};
$scope.ok = function()
{
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function()
{
$modalInstance.dismiss('cancel');
};
};