Codeigniter分页问题 - 未定义属性:$ pagination

I have searched here & Google but I don't get the solution for my Issue. Below my code for pagination :-

$this->load->library('pagination');
$config['base_url'] = base_url().'/books/';
$config['total_rows'] = 20;
$config['per_page'] = 10;
$config['num_links'] = 5;
$this->pagination->initialize($config);
exit;

I'm getting "Message: Undefined property: Welcome::$pagination" and "Fatal error: Call to a member function initialize() on a non-object in /var/www/code/application/controllers/welcome.php on line 25".

Can anybody help me what i did wrong. I also tried to initiate the pagination in autoload page. but getting the same error. Looking for experts response.

do you have this code in your controller ?

$data['pagination'] = $this->pagination->create_links();

then pass $data to your view

$this->load->view( 'results', $data );

then in your view an if check like:

<?php if ( strlen($pagination) ) { 

    echo $pagination;

   } else { 

 echo 'No search results' ; } ?>

You need to auto load the pagination library... just loading it in the function will not do.