0

I am facing some problem in drop down of angular js. Below is the html code

<select class="form-control" ng-init="projectName = options[0]" ng-model="projectName" name="projectName"  ng-options="project.name for project in projectsList track by project.id"  ng-class="{'submitted': submitted}" ng-selected="projectName" required>
 <option value="">Select Project</option>
</select>

all the things coming fine.

But what i want is after selecting value from drop down we submit the form and in success am getting the value what i have selected. Now i want to set this value for the drop down, how to do it ?

In jquery it works

$("dropdown").val('successCallBackValue');

but in angular how to do it

1 Answer 1

1

After the sucess of the form submit just set the value in the dropdown model value as,

$scope.projectName = yourValue; // whatever selected value you are getting.

<select class="form-control" ng-init="projectName = options[0]" ng-model="projectName" name="projectName"  ng-options="project.name for project in projectsList track by project.id"  ng-class="{'submitted': submitted}"  required>
 <option value="">Select Project</option>
</select>
Sign up to request clarification or add additional context in comments.

4 Comments

what value you are getting after submit ?
'$scope.projectName = $scope.projectsList.name;' am doing after success but again the value is not reflecting
You need to set the whole object in you scope value $scope.projectName =$scope.projectsList;
yeah i got it after assigning the whole object to the model.. Thanks

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.