2016-07-06 57 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

相关问题