I'm struggling to load a data set using ng-table. Could you please review my sample service and controller below?
app.service('ContactService', function () {
var bfLosses = [
{ idx: 0, uid: 'User 11', name: 'Name 11', area: 'Area 1'},
{ idx: 1, uid: 'User 12', name: 'Name 12', area: 'Area 1'},
{ idx: 2, uid: 'User 21', name: 'Name 21', area: 'Area 2'},
{ idx: 3, uid: 'User 22', name: 'Name 22', area: 'Area 2'}
];
}
I want to fetch the above array to populate the table in my controller.
app.controller("businessController", function ($scope,NgTableParams,ContactService){
$scope.tableParams = new NgTableParams({
group: "area"
},{
dataset: $scope.bfLosses
});
});
When I define the array inside the controller, everything works fine. However, I need to access it within the controller.