2016-09-29 81 views
0

我在角度js下拉時遇到了一些問題。下面是html代碼ng-select在angularjs中不起作用?

<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

形式提交剛纔設置的下拉模型值作爲值的研製成功後,

$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> 
+0

它不工作.. – Kishan

+0

你提交後得到什麼價值? – Hmahwish

+0

'$ scope.projectName = $ scope.projectsList.name;'我在成功之後做了,但是價值並沒有反映出來 – Kishan