user2560042
user2560042

Reputation:

Dynamically change state url page number for pagination in angualrjs

how to change/add the state and url for pagination example

.state('result.({pageNumber:[0-9]{1,4}})', {
            url: '/{pageNumber:[0-9]{1,4}}',
            templateUrl: 'tpl/search_result.html'
        })

in html

<a ui-sref="result.{{pageNumber}} ">{{ pageNumber }}</a> 

Now the a html is added perfectly with pageNumber but in config.router.js I tried to increment the pageNumber. but I have no idea.

How to increment the pageNumber in state and URL

Upvotes: 0

Views: 533

Answers (1)

Sudharsan S
Sudharsan S

Reputation: 15393

you mentioned state in wrong way. please use like this

.state('result.pageNumber', {
    url: '/:pageNumber',
    templateUrl: 'tpl/search_result.html'
  });

Change to this. you pass like this

<a ui-sref="result.pageNumber({pageNumber : pageNumber})">{{ pageNumber }}</a> 

Upvotes: 0

Related Questions