AngularJS でフォームを送信し、ブラウザのパスワード記憶機能を使用し、その後のログイン試行でブラウザにログイン フォームにユーザー名とパスワードを入力させると、$scope
モデルは自動入力に基づいて変更されません。
私が見つけた唯一の汚いハックは、次のディレクティブを使用することです。
app.directive("xsInputSync", ["$timeout" , function($timeout) {
return {
restrict : "A",
require: "?ngModel",
link : function(scope, element, attrs, ngModel) {
$timeout(function() {
if (ngModel.$viewValue && ngModel.$viewValue !== element.val()) {
scope.apply(function() {
ngModel.$setViewValue(element.val());
});
}
console.log(scope);
console.log(ngModel.$name);
console.log(scope[ngModel.$name]);
}, 3000);
}
};
}]);
問題は、返された値ngModel.$setViewValue(element.val());
に基づいてモデルもビューも変更されないことです。element.val()
どうすればそれを達成できますか?