I'm currently working on my project using angularjs
. I have implemented two divs that share the same controller. Here is the code for my controller:
var app=angular.module('categoryPageApp', []);
app.controller('NgProducts', function($scope,UpdateService) {
$scope.orderby=5;
$scope.pageNumber=1;
$scope.loadProducts=function($scope){
//here goes ajax call
};
});
The two divs in question with the same controller are as follows:
<div ng-app="categoryPageApp">
<div id="cat-products" ng-controller="NgProducts">
</div>
<div id="brand-filter" ng-controller="NgProducts">
</div>
</div>
It's clear that all variables are declared twice and the update function will be called twice as well. This duplication is not desired as a single http
call should suffice. Is there a way to work around this issue?
In addition, I am looking to implement a pager for my products using angular js. Any assistance or guidance on this matter would be greatly appreciated.