i have 3 tabs with pagination and sorting
so in my view:
<tabset>
<tab heading="Pending Transactions" ng-controller="Listing" ng-init="find('Pending')">
</tab>
<tab heading="On Hold Transactions" ng-controller="Listing" ng-init="find('OnHold')">
</tab>
<tab heading="Transaction Completed" ng-controller="Listing" ng-init="find('Completed')">
</tab>
</tabset>inside my controller i have method find():
$scope.find = function(status){
var Counter = $resource('/transactions/count',{status:status},{
query : {method:'GET', isArray:false}
});
$scope.populate = function(){
Transactions.query({status:status, page : $scope.currentPage, sort: $scope.sort, by : $scope.by},function(transactions){
$scope.transactions = transactions;
angular.forEach($scope.transactions, function(transaction){
$scope.checkboxes[transaction._id] = false;
});
});
};
$scope.sortBy = function(field){
if($scope.sort !== field){
$scope.by = true;
$scope.sort = field;
} else {
$scope.by = !$scope.by;
}
$scope.populate();
};
$scope.pageLimit = 10;
$scope.currentPage = 1;
Counter.query(function(count){
$scope.totalItems = count.total;
$scope.populate();
});
};my question is for example in pending list. i checked some items and then click "OnHold" button it should re-initialize the On Hold Transactions listing. is it posible to fire some method from outside of the scope?
Hi Jason,
I think you are missing some points in Angular. Can you put up a plunk/fiddle that show’s your problem in more detail.
With the current information I have, I would say but something like this is your template:<button ng-click='find("onHold")'>Onhold button</button>
But I’m not sure that is what you are asking.
BTW, you are using ng-init in a way that’s not intended use! From the manual:
The only appropriate use of ngInit is for aliasing special properties of ngRepeat, as seen in the demo below. Besides this case, you should use controllers rather than ngInit to initialize values on a scope.