简体   繁体   English

ng-select在angularjs中不起作用?

[英]ng-select is not working in angularjs?

I am facing some problem in drop down of angular js. 我在angular js下拉菜单中遇到一些问题。 Below is the html code 以下是html代码

<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 在jQuery中工作

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

but in angular how to do it 但在角度上怎么做

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM