1

我将 angularjs 用于 UI,将 codeigniter 用于后端(REST 服务器)。当我只使用 codeigniter 时,我知道如何进行分页,但我可以弄清楚如何应对这种情况。为此,我制作了一个函数来测试它。

因此,在 REST 服务器(codeigniter)上,我创建了用于测试的功能:

    $this->load->library('pagination');

    $config['base_url'] = 'http://localgost/test';
    $config['total_rows'] = 200;
    $config['per_page'] = 20;

    $this->pagination->initialize($config);

    $links = $this->pagination->create_links();
    $this->response($links, REST_Controller::HTTP_OK);

在 UI 端(angularjs)我得到 HTTP 请求的字符串:

<strong>1</strong><a href="http://localhost/test/20" data-ci-pagination-page="2">2</a><a href="http://localhost/test/40" data-ci-pagination-page="3">3</a><a href="http://localhost/test/20" data-ci-pagination-page="2" rel="next">&gt;</a><a href="http://localhost/test/180" data-ci-pagination-page="10">Last &rsaquo;</a>

但我不知道如何将此字符串转换为分页按钮。

有谁知道我怎么能做到这一点,如果可能的话?如果我通过此测试成功,我将轻松为我的所有页面进行分页。

4

1 回答 1

1

我有同样的问题,我用jquery来解决它:

创建一个 div 标签来显示分页按钮

<div class="pagination"></div>

并使用 jquery:

jQuery('.pagination').html(data.pages);

并在 codeigniter 中尝试使用 angular url 作为 base_url :

$config['base_url'] = '#/users;
$config['total_rows'] = 100;
$config['per_page'] = 10; 
$config['use_page_numbers'] = TRUE;
$config['uri_segment'] = 4;
于 2016-08-10T13:05:39.740 回答