2016-07-06 58 views
1

有人可以幫助我處理下面的情況。角度js從一個參數的HTML控制器方法

我有一個手風琴,手風琴的點擊它擴大了。

取決於點擊頭,我想加載數據,甚至預加載數據。

我在控制器的功能與下面的簽名

$scope.getDetailsFn = function(Id){ 
    $scope.Details = "I am possible" 
}; 

手風琴是如下

<uib-accordion close-others="oneAtATime" > 
    <uib-accordion-group heading="{{x.id}}" ng-repeat="x in xs" > 
     //Is the below possible or calling the below on ng-click possible 
     {{getDetailsFn({{x.id}})}} 
     {{Details}} 
     Message: {{x.message}} 
     </br> 
    </uib-accordion-group> 
</uib-accordion> 

回答

1

從你的問題,貌似要顯示的標題的點擊數據?只要做到這一點

<uib-accordion close-others="oneAtATime" > 
<uib-accordion-group heading="{{x.id}}" ng-repeat="x in xs" ng-click="getDetailsFn(x.id)"> 
    {{Details}} 
    Message: {{x.message}} 
    </br> 
</uib-accordion-group> 
</uib-accordion> 

而在控制器,你會得到'x',所以顯示基於x的細節。

+1

謝謝,它的工作!不知道我可以不用{{}}直接引用x.id。 – user2934433

相關問題