Created
July 11, 2014 14:28
-
-
Save aya-eiya/8f783317e161fd2bb665 to your computer and use it in GitHub Desktop.
AngularJSでValidationをかけたインプット項目に、invalidになる値を初期値として入れると値が見えなくなる ref: http://qiita.com/aya_eiya/items/20d5ada0ee3477d8843d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ja"><head><meta charset="utf-8" /></head> | |
<body> | |
<div ng-app="app" ng-controller="validCtrl"> | |
<form name="form" novalidate> | |
<input ng-model="default" ng-minlength="7" id="invalidDefault" name="default"/>{{ form.default.$error }} | |
<p>default:{{ default }}</p> | |
<p>invalidDefault.value:<span id="output"></span></p> | |
<script> | |
setInterval(function(){output.innerHTML = invalidDefault.value},5); | |
</script> | |
</form> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script> | |
<script> | |
var app = angular.module('app', []); | |
app.controller('validCtrl',['$scope',function ($scope) { | |
$scope.default = '123456'; | |
setTimeout(function(){$scope.default='78945677';$scope.$apply();},3000); | |
setTimeout(function(){$scope.default='415647';$scope.$apply();},6000); | |
}]); | |
</script> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment