【问题标题】:Angular js Controller method from HTML with a parameter带有参数的HTML的Angular js Controller方法
【发布时间】:2016-07-06 07:31:55
【问题描述】:

有人可以帮我处理以下情况吗?

我有一个手风琴,点击手风琴它会展开。

根据点击的标题,我想加载数据,甚至预加载数据。

我在控制器中有一个具有以下签名的函数

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

【问题讨论】:

    标签: javascript jquery html angularjs angular-ui-bootstrap


    【解决方案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的细节。

    【讨论】:

    • 谢谢,成功了!不知道我可以在没有 {{ }} 的情况下直接引用 x.id。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2023-03-29
    • 2015-09-23
    • 1970-01-01
    • 2021-07-12
    相关资源
    最近更新 更多