【发布时间】:2016-03-07 07:28:22
【问题描述】:
我正在创建一个模态对话框并尝试在对话框关闭时读取字段,但是在编辑输入时,输入字段的 ng-model 被设置为未定义。对于Plunk,如果您单击对话框按钮,然后在不修改文本字段的情况下按确定,它将显示“blah”。但是如果你完全修改文本输入,那么什么都不会显示。
对话框模板是:
<script type="text/ng-template" id="simpleModal.html">
<div class="modal-header">
<h3 class="modal-title">Simple Modal</h3>
</div>
<div class="modal-body">
<div class="form-group">
<label for="emailInput">Email</label>
<input id="emailInput" type="email" class="form-control" ng-model="user.email">
</div>
</div>
<div class="modal-footer">
<button class="btn" type="button" ng-click="ok()">Ok</button>
</div>
</script>
还有模态对话框的控制器:
app.controller('SimpleModalController', function($scope, $uibModalInstance, $log) {
$scope.user = {
email: "blah"
};
$scope.ok = function() {
$log.debug('simpleModal ok called ' + $scope.user.email);
$uibModalInstance.close($scope.user.email);
};
});
我看到了对 https://stackoverflow.com/a/22768720/552936 的引用,但我已经更改了代码以反映这一点,但它并没有解决问题。
【问题讨论】:
-
type is email - 如果您输入有效的电子邮件,它会起作用。如果它不是一个有效的电子邮件,它将是未定义的。
标签: angularjs angular-ui-bootstrap angular-ui