javascript - Form fields / Placeholder and value -
i have form field want change if condition true.
<input type="email" name="useremail" id="useremail" class="form-control" ng-class="{'invalid-signup': signupform.useremail.$invalid && signupform.useremail.$dirty, 'valid-signup': signupform.useremail.$valid && signupform.useremail.$dirty}" placeholder="primary contact email." ng-required="true" ng-maxlength="30" ng-minlength="5" ng-model="signupmodel.useremail"/> <div ng-show="signupform.useremail.$dirty && signupform.useremail.$invalid"> <p ng-show="signupform.useremail.$error.required">email required.</p> <p ng-show="signupform.useremail.$error.pattern">email not valid.</p> <p ng-show="signupform.useremail.$error.minlength">email short, min 5 characters.</p> <p ng-show="signupform.useremail.$error.maxlength">email long, max 30 characters.</p> </div>
so have 1 flag variable , if true want change field placeholder , value something.
$scope.isgoogleloginworking = true;
is there way doing that.
thanks in advice.
you can use ternary operator
<input type="email" name="useremail" id="useremail" class="form-control" ng-class="{'invalid-signup': signupform.useremail.$invalid && signupform.useremail.$dirty, 'valid-signup': signupform.useremail.$valid && signupform.useremail.$dirty}" placeholder="{{isgoogleloginworking?'primary contact email.':'something else'}}" ng-required="true" ng-maxlength="30" ng-minlength="5" ng-model="signupmodel.useremail" ng-value="isgoogleloginworking?signupmodel.useremail:'something else'"/>
wiki
Comments
Post a Comment