【发布时间】:2015-05-19 11:45:23
【问题描述】:
我已经实现了 ion-tabs 来显示我最近查看的产品和搜索结果。我将最近的项目存储在本地存储中,并将其绑定到我的 html 中。最初这工作正常,但列表经常消失。该列表在 html 中没有绑定。
我遇到了一些解决方案,例如 - 使用 $rootScope.apply()、$timeout() 等。我已经尝试了一切。现在失踪人数减少了。但有时列表仍然会消失。除非我重新安装应用程序,否则列表不会显示。
在我的控制器中,我正在这样做:-
$scope.$on( "$ionicView.loaded", function( scopes, states ) {
$scope.init();
});
$timeout(function() {
$rootScope.$apply(function()
{
$rootScope.viewedList = JSON.parse(window.localStorage.getItem("viewedList") || "[]");
});
}, 10);
以下代码在我的 html 中:-
<ion-tabs class="tabs-striped tabs-top tabs-background-grey tabs-positive">
<ion-tab title="Viewed items">
<ion-content class="has-header has-subheader has-tabs-top padding" style="padding:40px 0" overflow-scroll="true" has-bouncing="false">
<div ng-repeat="item in viewedList | reverse " >
<ion-list>
<ion-item class="item item-divider" ng-click="productSearch(item.productId)">
<span style="font-weight:bold"> {{item.Description}}</span><br>
{{item.productId}}
</ion-item>
</ion-list>
</div>
<div ng-if="viewedList.length===0 || viewedList==null">
<ion-item>No Viewed Items
</ion-item>
</div>
</ion-content>
</ion-tab>
<ion-tab title="Search Results">
<!-- Another tab here-->
</ion-tab>
</ion-tabs>
有人可以帮我解决这个问题吗???
【问题讨论】:
-
你能在 jsfiddle 中重现吗?
-
我不能理解你的问题,比如列表就这样消失了?
-
@sioesi 是的,,,消失了,,好像失去了列表的引用,,,
标签: angularjs angularjs-scope angularjs-ng-repeat ionic-framework ionic