2014-02-10 18 views
0

我試圖發送一些信息到我的loadSecondary函數,但我不知道如何訪問有關我的數組或我選擇的對象的任何信息。使用ng-selected與<select>

我試過發送$index,p,$parent.$index,$parent.p,它們都是未定義的。

有關我選擇的對象或它在數組中的位置的信息,我可以發送給我的函數嗎?

<select ng-model="secondPres" ng-options="p.name for p in presentations"> 
     <option value="" ng-selected="loadSecondary(???)">-- Choose a presentation to merge with --</option> 
</select> 
+0

'loadSecondary(secondPres)'或'p.name' - 其中之一:) – tymeJV

+0

@tymeJV這似乎沒有工作 – Houseman

回答

0

而不使用NG-選擇,我會派人監視在$ scope.secondPres在你的控制器,然後在其上運行loadSecondary:

$scope.$watch('secondPres', function(s) { 
    if(typeof s !== 'undefined') { 
     $scope.loadSecondary(s); 
    } 
}); 
+0

我更喜歡這個解決方案 – Houseman

0

因爲我無法ng-selected發送任何東西,我送什麼都沒有。

我結束了剛剛訪問$scope.secondPres,從函數內部