ng-select在angularjs中不起作用?

时间:2016-09-29 11:59:16

标签: javascript angularjs

我在降低角度js方面遇到了一些问题。以下是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>
所有事情都很顺利。

但我想要的是从下拉菜单中选择价值后我们提交表格并成功获得我所选择的价值。现在我想为下拉列表设置此值,该怎么做?

在jquery中它可以工作

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

但是角度怎么做

1 个答案:

答案 0 :(得分:1)

表单提交成功后,只需将下拉模型值中的值设置为

即可
$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>