Mohaideen Ismail
Mohaideen Ismail

Reputation: 314

Fill the textbox value in angularJs

I have working on Edit Profile page in angular Js

Normally List of details will be show. When click on one list , I called the one method

 $scope.editContact = function(user){
            $('#editContactSection').show();
            $scope.eUser = user;
        }

Then I assigned the text box value by eUser

 <input type="text" class="form-control" id="fname"  ng-model="fname" name="fname" ng-minlength='3' value="{{eUser.firstname}}" required>
                            <div ng-show='editContacForm.fname.$error.minlength' class='error'>Enter atleast 3 characters</div>

Here i got the textbox value in input tag in console like value="somename". Value is assigned correctly. But i can't see in textbox in browser window

And how to change the drop down list value. That drop down list value filled by angular js ng-repeat

Upvotes: 0

Views: 5862

Answers (2)

vanarajcs
vanarajcs

Reputation: 978

Try this

$scope.editContact = function(user){
   $('#editContactSection').show();
   $scope.eUser = user;
   $scope.fname = $scope.eUser.firstname;
}

Or

<input data-ng-init="fname=eUser.firstname" type="text" class="form-control" id="fname"  ng-model="fname" name="fname" ng-minlength='3' required>
                            <div ng-show='editContacForm.fname.$error.minlength' class='error'>Enter atleast 3 characters</div>

Upvotes: 3

kriznaraj
kriznaraj

Reputation: 484

Try setting ng-model='eUser.firstname'

as in

<input type="text" class="form-control" id="fname"  ng-model="eUser.firstname" name="fname" ng-minlength='3'  required>

Upvotes: 3

Related Questions