【发布时间】:2014-07-24 13:42:19
【问题描述】:
我正在使用基于 AngularJS 的 Ionic 框架开发移动应用程序。
在一个指令上,我正在循环使用 ng-repeat 的 JSON 数组,并应用 ng-if 的条件,见下文:
<ion-content class="has-header has-subheader" >
<ion-slide-box">
<ion-slide
ng-if="invocation.title_id == titleid"
ng-repeat="invocation in invocations" >
<h3>{{invocation.id}}</h3>
<div ><h1>{{invocation.invocation_frensh }}</h1></div>
<div ><h1>{{invocation.invocation_ar}}</h1></div>
<div ><h1>{{invocation.invocation_franko}}</h1></div>
<div ><h1>{{invocation.comments_fr}}</h1></div>
<div ><h1>{{invocation.comments_ar}}</h1></div>
</content>
</ion-slide>
</ion-slide-box>
<p>{{invocation.id}}</p>
</ion-content>
关键是最后一个p什么都没有显示。
我知道 $scope 不一样,但在最后一个 "p" 或 ng-repeat 之外的任何其他组件上,我需要拥有相同的数据才能与之交互。
例如,我想在获取"{{invocation.id}}" 的页脚上添加一个按钮。如果 ng-repeat "h3" 中的 invocation.id 等于 3 我希望它在 "p" 中等于 3
我该怎么做?
感谢您的帮助
编辑: 事实上,我希望 invocations[index].id 在循环外的“p”中,其中 index 等于显示的幻灯片。
【问题讨论】:
-
调用在循环之外没有意义。你想在 p 标签中引用哪个调用对象?
-
如果重复多次怎么办 - 你想在页脚中显示哪个 invocation.id?最后一个?
-
感谢 cmets。我想看到与循环中显示的相同的 invocation.id。我应该在离子载玻片上说得更具体一些吗?
-
事实上,我希望在循环外的“p”中调用 [index].id,其中 index 等于显示的幻灯片。
标签: angularjs angularjs-ng-repeat ionic-framework