我将 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">></a><a href="http://localhost/test/180" data-ci-pagination-page="10">Last ›</a>
但我不知道如何将此字符串转换为分页按钮。
有谁知道我怎么能做到这一点,如果可能的话?如果我通过此测试成功,我将轻松为我的所有页面进行分页。