如何使用ng-if将可见数据转发到第1页 [英] How to bring visible data forward to 1st page using ng-if
问题描述
我在ng-repeat上显示数据时遇到问题,假设我有这组样本数据
I have problem displaying data on ng-repeat, lets say I have this set of sample data
$scope.sample={"a","b","c","d","e","f","test"}
表格将显示数据,如果样本包括'test'
table will show data if sample includes 'test'
<tr ng-repeat="data in sample track by $index" ng-if="data.includes('test')">
我的表格将在每页显示4个数据
my table will show 4 data in each page
$scope.table = new ngTableParams({
page: 1,
count: 4 })
但是,当你运行代码时,第一页是空白的,我需要导航到第2页看到数据测试,因为它位于第7位。
我的问题是,有没有一个解决方案可以带来可见的领域?让我们说因为表中只能看到1个数据,所以它应该只有1页而不是2页。
谢谢
我尝试了什么:
我被困住了,需要一些帮助。
谢谢
However, when you run the code, the 1st page is blank, I need to navigate to the 2nd page to see the data 'test' as it's on the 7th position.
My question is, is there a solution to bring visible field forward? and let's say since only 1 data is visible in the table, it should only have 1 page instead of 2 page.
Thanks
What I have tried:
I'm stuck, will need some help.
Thanks
推荐答案
scope.sample = {a,b,c,d,e ,f,test}
scope.sample={"a","b","c","d","e","f","test"}
表将显示数据,如果样本包含'test'
table will show data if sample includes 'test'
<tr ng-repeat="data in sample track by
index ng-if < span class =code-keyword> = data.includes('test') >
index" ng-if="data.includes('test')">
我的表格将在每页显示4个数据
my table will show 4 data in each page
scope.table = new ngTableParams({
page: 1 ,
count: 4 })
scope.table = new ngTableParams({ page: 1, count: 4 })
但是,当你运行代码时,第一页是空白的,我需要导航到第2页以查看数据'test',因为它位于第7位。
我的问题是,有没有一个解决方案可以带来可见的字段前进?让我们说因为表中只能看到1个数据,所以它应该只有1页而不是2页。
谢谢
我尝试了什么:
我被困住了,需要一些帮助。
谢谢
However, when you run the code, the 1st page is blank, I need to navigate to the 2nd page to see the data 'test' as it's on the 7th position.
My question is, is there a solution to bring visible field forward? and let's say since only 1 data is visible in the table, it should only have 1 page instead of 2 page.
Thanks
What I have tried:
I'm stuck, will need some help.
Thanks
这篇关于如何使用ng-if将可见数据转发到第1页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!