I am trying to create a pagination directive. When total_for_pagination is populated, the proper HTML for the pagination is created.
My html: max = max per page
<pagination data-number="{{ total_for_pagination }}" data-max="50"></pagination>
My directive:
link: function(scope, element, attrs){
scope.$watch(function(){return attrs.number;}, function(){
//Need to watch because there is a query to db to know how many elements to page.
var page_element = '<ul>';
for(var i = 0; i*attrs.max<attrs.number; i+=1){
page_element += '<li class="pagination"><a ui-sref="users({start: '+i*attrs.max+', end: '+((i*attrs.max)+(attrs.max-1))+'})">'+i+'</a></li>';
}
page_element += '</ul>';
element.append(page_element);
});
}
What is happening is that when I inspect my html they are as they should be but ui-sref is note changing the state when I click on it. When I just place the same code, works fine.
What I am doing wrong? Thanks!