入力の値を読み取り、一連の真偽をトリガーする関数を作成しようとしていますが、以下のコードは "passStrength is not defined"を返し続けます。 私が見つけたことから、oninputはAngularではサポートされていません。どのように角度でこれを達成することができますか?私のコントローラ内のoninputがAngularで動作していません。代わりに?
:
$scope.passStrength = function(input) {
if (input.value.toLowerCase().indexOf(/[a-z]/) > -1) {
$scope.lwrChar = true;
console.log('lower ' + $scope.lwrChar);
} else if (input.value.toUpperCase().indexOf(/[A-Z]/) > -1) {
$scope.uprChar = true;
console.log('upper ' + $scope.uprChar);
} else if (input.value.indexOf() == !isNaN(n)) {
$scope.nbrChar = true;
console.log('number ' + $scope.nbrChar);
} else if (input.value.length >= 8) {
$scope.countChar = true;
console.log('count ' + $scope.countChar);
}
};
と私のマークアップ:
<input id="password" oninput="passStrength()" />
それを証明plunkerを作成しました。 https://docs.angularjs.org/api/ng/directive/ngChange –