0

I started working on angular js. My problem is that I have a text field on which validation is performed, but I want to echo the value of this text field from Db but it is not working......

<input type="text"   pattern="[A-Za-z].{3,}"  required 
  name="uname" id="uname"  ng-minlength="4" ng-model="uname" class="txtbox-short"  value="<?php echo $unamedb; ?>"> 
<span class="help-inline" ng-show="submitted && xForm.uname.$error.required"></span>
<span class="help-inline" ng-show="xForm.uname.$error.minlength"  style="color:red;">Too Short!</span>
1
  • 1
    Please edit your question with the code instead of putting it in the comments, it will make it easier to read Commented Feb 15, 2015 at 5:01

1 Answer 1

1

You should set $scope.uname. If you set your value like that value="<?php echo $unamedb; ?>", than value in ng-model will be not <?php echo $unamedb; ?>. You should use ng-init. Like that ng-init="uname=<?php echo $unamedb; ?>". Finish code input form:

<input type="text" pattern="[A-Za-z].{3,}" required name="uname" id="uname" ng-minlength="4" ng-model="uname" class="txtbox-short" ng-init="uname=<?php echo $unamedb; ?>">
Sign up to request clarification or add additional context in comments.

1 Comment

and, sure, php echo isn't a better way to set data on input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.