Angularjs Chrome autocomplete dilemma

后端 未结 15 1734
野性不改
野性不改 2020-12-05 06:56

I have a simple login form which works just peachy unless you use Chrome\'s auto complete feature.

If you start typing and use the auto complete feature and it auto

15条回答
  •  鱼传尺愫
    2020-12-05 07:09

    You could watch the email field value and everytime the value in that field is changing, you could trigger a "change"-event on the password field. This events trigger all the ng-model magic on that field and updates the model.

    module.directive("autocompleteFor", function () {
        return {
            restrict: "A",
            link: function ($scope, $element, $attrs) {
                $scope.$watch($attrs.autocompleteFor, function () {
                    $element.triggerHandler("change");
                })
            }
        }
    });
    

    With this directive you could handle that scenario like this:

    
    
                           -----------------------------
    

提交回复
热议问题