Javascript 打开时angularjs手风琴载荷数据
我们正在使用angularjs手风琴,然而,我们的手风琴相当大,并且包含很多数据。 我们正在做的是在手风琴打开时加载数据。ie不呈现内部内容,直到用户点击手风琴标题。 下面是我们目前使用手风琴的方式:-Javascript 打开时angularjs手风琴载荷数据,javascript,angularjs,angular-ui,Javascript,Angularjs,Angular Ui,我们正在使用angularjs手风琴,然而,我们的手风琴相当大,并且包含很多数据。 我们正在做的是在手风琴打开时加载数据。ie不呈现内部内容,直到用户点击手风琴标题。 下面是我们目前使用手风琴的方式:- <accordion close-others="false"> <accordion-group heading="{{result.ReceivedDateTime}}{{result.OrderName}}" ng-repea
<accordion close-others="false">
<accordion-group heading="{{result.ReceivedDateTime}}{{result.OrderName}}" ng-repeat="result in resultsbyorder">
<table id="tbl" class="table table-striped table-bordered" ng-repeat="Grid in result.Results">
<tr ng-repeat="item in Grid" ng-show="$first">
<th ng-repeat="somat in item">
{{somat.ColumnHeader}}
</th>
</tr>
<tr ng-repeat="item in Grid">
<td ng-repeat="somat in item">
{{somat.ColumnValue}}
</td>
</tr>
</table>
</accordion-group>
</accordion>
{{somat.ColumnHeader}
{{somat.ColumnValue}
作为旁注,是否可以只渲染屏幕上显示的手风琴标题,然后在滚动时渲染其余的标题?我认为最好在第一次打开时编译一次 这样,您就不必再次编译相同的内容,即使它是在上次打开手风琴组之前编译的 在我脑海中,我可以想到使用
ng开关
指令。您必须知道,此指令允许基于case变量有条件地显示DOM元素
但是,该指令与ng show
或ng hide
指令不同之处在于,在匹配相应的case变量之前,不会编译case语句中的内容
因此,您可以在HTML文档中进行以下设置:
<accordion close-others="oneAtATime">
<accordion-group is-open="isopen">
<accordion-heading>
Accordion Heading
</accordion-heading>
<div ng-switch on="isopen">
<div ng-switch-when="true">
<!-- Content that should be compiled when the accordion is opened
goes here -->
</div>
</div>
</accordion-group>
</accordion>
另外,我相信ng if
指令也能达到同样的效果。因此,您可以使用这两种指令中的任何一种来实现您的要求。我现在正在做这件事,并且发现Angular喜欢使用一个集合(即使它只是一个元素)来制作手风琴,也就是说,如果您这样做,您可以将打开的绑定到该组上的元素,然后在控制器中的该组上设置一个监视。考虑下面的内容(考虑使用Ajax调用来获取数据而不是登录到控制台):
var ngtestapp=angular.module(“ngtestapp”,['ui.bootstrap']);
ngtestapp.controller(“ngTestController”,函数($scope){
$scope.userComments=[
{
罗维德:123,
创建日期:新日期(2015年1月2日0月0日0月0日),
创建人:564,
信息:'Carpe Dieum',
CreatedByDisplayName:“Daniel Graham”
},
{
罗维德:124,
创建日期:新日期(2015年1月5日0月0日0月0日),
创建人:562,
信息:“太棒了”,
CreatedByDisplayName:“彼得·格里芬”
}
];
$scope.feedbackGroup=[{title:“用户评论”,open:false}];
$scope.$watch('feedbackGroup',函数(feedbackGroup){
if(反馈组[0]。打开){
log(“打开的反馈组”);
}否则{
log(“关闭的反馈组”);
}
},对);
$scope.userTaskNote=“用户任务测试说明”;
});代码>
.nav、.pagination、.carousel、.panel title a{cursor:pointer;}
-
用户名
注释
手风琴不公开任何活动。您可以修改accordion源代码并添加打开/关闭事件。