1

我有一个我建议城市的文本框。我已经使用了 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);
    }
}

http://plnkr.co/edit/JuIuAXZQVsJlEzjM0faT?p=preview

4

1 回答 1

0

OK, so there was a bug fixed in the 0.4.0 version of http://angular-ui.github.io/bootstrap/

The change done in https://github.com/angular-ui/bootstrap/issues/591 fixes your issue as well. It wasn't released yet but here is the working plunk with the version from continuous integration server:

http://plnkr.co/edit/17UOgHJd82otwC6TS7s9?p=preview

于 2013-07-10T16:52:30.927 回答