【发布时间】:2013-07-10 08:01:01
【问题描述】:
我有一个我建议城市的文本框。我已经使用了 angualar-ui typeahead 的建议。现在一切似乎都运行良好。
只是当我使用 $scope.cancel 通过角度重置表单时,它不会反映在 UI 上,而且模型似乎也没有重置为正确的值,因为表单似乎很脏。对于没有预先输入的字段,效果很好。
有人遇到过这个吗?
代码:
<input placeholder='City' type="text" ng-model="form.city" typeahead="x for x in suggestCity($viewValue)" />
function ContactController($scope, $http) {
$scope.cancel = function() {
$scope.form = angular.copy($scope.userprofile.contact);
}
}
【问题讨论】:
-
能否分享您的完整 html 或小提琴代码
-
编辑问题以添加 plnkr 代码
标签: angularjs angular-ui angular-ui-bootstrap