Updating current list from one controller to another in angularjs? - angularjs

Im having issues updating a list. I have tried both rootscope and using factory but it just doensn't update the view. Rather it remains the same. The only time the update works is if the list is empty to begin with otherwise the original load is always there. Appreciate any suggestions.
Here is my attempt using rootscope:
rootscope alternative
app.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/',{
replace:true,
templateUrl: 'views/questions.html',
controller: 'SiteController as vm'
})
.when('/categories',{
templateUrl: 'views/categories.html',
controller: 'CategoriesCtrl as cm'
})
.when('/categories/:name*',{
templateUrl: 'views/questions.html',
controller: 'SiteController as vm'
})
.otherwise({
redirectTo: '/'
})
}]);
index.html
<div class="col-xs-12 col-sm-8 col-md-8" ng-view>
All views load here
</div>
questions.html
<table class="table table-questions">
<thead>
</thead>
<tbody>
<tr dir-paginate-start="q in vm.allquestions>
<td>
<a class="questionlinks" ng-click="vm.viewquestion(q.idquestion)> {{q.question}} </a><h4></h4>{{q.date }}
</td>
<td class="text-center"><span class="box box-blue"> {{q.clicks}} </span></td>
</tr >
</tbody>
</table>
categories.html
<div class="wrapper content content-categories content-tags" id="categories_content">
<h2>Categories</h2>
<div class="col-md-12">
<ul class="list-tags" ng-repeat="c in cm.categories">
<li><a ng-href="#/categories{{c.categoryurl}}" ng-click="cm.getCategoryQuestions(c.idcategory)">{{c.categoryname}}</a></li>
</ul>
</div>
<div class="col-md-12">
<nav>
</nav>
</div>
</div >
Now the controllers
SiteController
(function () {
'use strict';
angular
.module('app')
.controller('SiteController', SiteController);
SiteController.$inject = ['$http','$route','$routeParams','$rootScope'];
function SiteController($http,$route,$routeParams,$rootScope) {
var vm = this;
vm.allquestions=[];
vm.thequestions=thequestions;
init();
function init(){
thequestions();
}
function thequestions() {
var url;
$rootScope.$on('updateQs',function(event, obj){
url=obj;
$http.get(url).then(function (response) {
vm.allquestions=response.data;
});
});
$http.get("/getlatestquestions").then(function (response) {
vm.allquestions=response.data;
});
}
}
})();
Categories Controller
(function () {
'use strict';
angular
.module('app')
.controller('CategoriesCtrl', CategoriesCtrl);
CategoriesCtrl.$inject = ['$http','$rootScope'];
function CategoriesCtrl($http,$rootScope) {
var cm = this;
cm.categories=[];
cm.categoryquestions=[];
//CATEGORIES
cm.getCategories=getCategories;
cm.getCategoryQuestions= getCategoryQuestions;
init();
function init(){
getCategories();
}
//CATEGORIES RELATED
function getCategories() {
var url="/getcategories";
var categoryPromise=$http.get(url);
categoryPromise.then(function (response) {
cm.categories=response.data;
})
}
function getCategoryQuestions(idcategory) {
var url="/getcategoryquestions"+idcategory;
$rootScope.$emit('updateQs',url);
}
}
})();
Factory alternative
Added this in the app.module file under app.config
app.factory("newquestions", function () {
var questions = {};
return {
setQs: function (value) {
questions = value;
},
getQs: function () {
return questions;
}
};
});
This in SiteController
(function () {
'use strict';
angular
.module('app')
.controller('SiteController', SiteController);
SiteController.$inject = ['$http','$route','$routeParams','newquestions'];
function SiteController($http,$route,$routeParams,newquestions) {
var vm = this;
vm.allquestions=[];
vm.thequestions=thequestions;
init();
function init(){
initial();
thequestions();
}
function initial(){
newquestions.setQs("/getlatestquestions");
}
function thequestions() {
var url=newquestions.getQs();
$http.get(url).then(function (response) {
vm.allquestions=response.data;
});
}
}
})();
This in CategoriesController
(function () {
'use strict';
angular
.module('app')
.controller('CategoriesCtrl', CategoriesCtrl);
CategoriesCtrl.$inject = ['$http','newquestions'];
function CategoriesCtrl($http,newquestions) {
var cm = this;
cm.categories=[];
cm.categoryquestions=[];
//CATEGORIES
cm.getCategories=getCategories;
cm.getCategoryQuestions= getCategoryQuestions;
init();
function init(){
getCategories();
}
//CATEGORIES RELATED
function getCategories() {
var url="/getcategories";
var categoryPromise=$http.get(url);
categoryPromise.then(function (response) {
cm.categories=response.data;
})
}
function getCategoryQuestions(idcategory) {
var url="/getcategoryquestions"+idcategory;
newquestions.setQs(url);
}
}
})();

It wouldn't work. There is no way to know either of your controllers to know that list has changed.
Solution
Use event broadcasts.
Broadcast or emit an event from two controllers. And use it as a trigger point.

Related

Why my service does not share data between controllers?

I built a factory to get Data from the Database and pass to all controllers in my application like this:
(function () {
angular.module('appContacts')
.factory('dataService', ['$http', dataService]);
function dataService($http) {
return {
getCurrentOrganization: getCurrentOrganization,
};
function getCurrentOrganization(id) {
return $http({
method: 'GET',
url: '/api/organization/' + id + '/contacts'
})
}
}
})();
And I have a view like this:
<div ng-app="myapp">
<div ng-controller="contactController">
<a ui-sref="organization({Id: organization.id})" ng-click="vm.setCurrentOrganization(organization)"> {{organization.organizationName }}</a>
</div>
</div>
That link redirect from a view the view contactsView.html to a detail view organizationDetail.html managed by a second controller:
....
.state("home", {
url: "/",
templateUrl: "views/contactsView.html",
controller: "contactsController",
controllerAs: "vm"
})
.state("organization", {
url: "/organization/:Id",
templateUrl: "views/organizationDetail.html",
params: { Id: null },
controller: "organizationsController",
controllerAs: "vm"
})
...
My problem is that I get the data, I see in the console, but when the new URL comes into place, the Data is gone and the view is shown empty.
How could I use the data produced in the factory in the second Controller?
EDIT:
Here are the Controllers:
//organizationsController.js
(function () {
"use strict";
angular.module('appContacts')
.controller('organizationsController', function organizationsController(dataService) {
var vm = this;
vm.setCurrentOrganization = function (organization) {
vm.theOrganization = organization;
vm.visible = true;
dataService.getCurrentOrganization(vm.theOrganization.id).then(function (result) {
vm.organizationData = result.data;
}, function () {
vm.errorMessage = "Failed to load" + Error;
});
}
});
})();
And the contactsController:
//contactsController.js
(function () {
"use strict";
angular.module('appContacts')
.controller('contactsController', function contactsController(dataService) {
var vm = this;
vm.visible = false;
activate();
function activate() {
dataService.getAllContacts().then(function (result) {
vm.allcontacts = result.data;
}, function () {
vm.errorMessage = "Failed to load" + Error;
});
dataService.getAllOrganizations().then(function (result) {
vm.organizations = result.data;
}, function () {
vm.errorMessage = "Failed to load" + Error;
});
}
});
})();
The problem is that I click the llink in the view A (contactsView.html/ContactsViewController) and I should end in the VIEW B (OrganizationDetails.html/organizationController), using the Data fetch in the service.
You are doing it wrong here
<div ng-app="myapp">
<div ng-controller="contactController">
<a ui-sref="organization({Id: organization.id})" ng-click="vm.setCurrentOrganization(organization)"> {{organization.organizationName }}</a>
</div>
</div>
Your contactController does not have the function setCurrentOrganization. Instead its in another controller. you can remove the code ng-click="vm.setCurrentOrganization(organization)" from the HTML. and read the id using $stateParams in the organizationsController. After getting the id, use it call the service as below:
dataService.getCurrentOrganization(id).then(function (result) {
vm.organizationData = result.data;
}, function () {
vm.errorMessage = "Failed to load" + Error;
});

angularjs: unable to get data from factory

I am unable to get my json data from factory and show it in table.
When I was using the $scope object, it was working fine but then I saw in official website that they don't recommend using $scope anymore. So I am using this parameter as suggested in demo examples. And now my code is not working anymore.
Please see my code and help me in this regard:
HTML:
<body ng-app="admin">
<div ng-controller="controller1 as ctrl1">
<div class="container">
<div class="row">
<div class="col-sm-12">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>IP</th>
<th>Time</th>
<th>No. of times</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="iprow in ctrl1.ipLog">
<td>{{iprow.ip}}</td>
<td>{{iprow.time}}</td>
<td>{{iprow.count}}
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<script src="../framework/angular/angular.min.js"></script>
<script src="javascript/app.js"></script>
<script src="javascript/controllers/profileController.js"></script>
</body>
angular app.js
var admin = angular.module('admin', ['myController']);
admin.factory('simpleFactory', function ($http) {
var ipLog = [];
var factory = {};
factory.getIpLog = function () {
// Simple GET request example:
return $http({method: 'GET', url: 'mysql-query.php'}).
then(function successCallback(response) {
ipLog = response.data;
return ipLog;
}, function errorCallback(response) {
console.log(response.data);
return ipLog;
});
};
return factory;
});
angular profileController.js
var myController = angular.module('myController', []);
myController.controller('controller1', ['simpleFactory', function (factory) {
this.ipLog = [];
init();
function init() {
var myDataPromise = factory.getIpLog();
myDataPromise.then(function (result) {
// this is only run after getData() resolves
this.ipLog = result;
});
}
}]);
Your view:
<body ng-app="admin">
<div ng-controller="controller1">
...
<tr ng-repeat="iprow in ipLog">
...
</body>
factory code:
var admin = angular.module('admin', []);
admin.factory('simpleFactory', function ($http) {
var factory = {};
factory.getIpLog = function () {
// Simple GET request example:
return $http({method: 'GET', url: 'mysql-query.php'});
};
return factory;
});
Grab the factor module inside the controller.
Controller:
var myController = angular.module('myController', ['admin']);
myController.controller('controller1', ['simpleFactory', function (factory) {
$scope.ipLog = [];
function init() {
var myDataPromise = factory.getIpLog();
myDataPromise.then(function (result) {
$scope.ipLog = result.data;
});
}
init();
}]);
in app.js
factory.getIpLog = function () {
// Simple GET request example:
return $http({method: 'GET', url: 'mysql-query.php'});
};
in profileController.js
myController.controller('controller1', ['simpleFactory', function (factory) {
this.ipLog = [];
init();
function init() {
var myDataPromise = factory.getIpLog();
myDataPromise.then(function (success) {
this.ipLog = success;
}, function(error){
console.log(error);
});
}
}]);
In your profileController.js, this in this.ipLog=[] refers to myController but when when you are assigning value to this.ipLog=result, this here doesn't refer to myController. SO your this.ipLog is always an empty array.
try this code:
var myController = angular.module('myController', []);
myController.controller('controller1', ['simpleFactory', function (factory) {
var fixedThis=this;
fixedThis.ipLog = [];
init();
function init() {
var myDataPromise = factory.getIpLog();
myDataPromise.then(function (result) {
// this is only run after getData() resolves
fixedThis.ipLog = result;
});
}
}]);
Please try this code and tell if it works.

Not able to display the home page in Asp.Net Angularjs webAPI

I am new in AngularJs. I have developed a small application which will conduct CRUD Operation. This is my Project Structure
I am able to run my webapi successfully and retrieve the data. To call my WebApi I have created a Angular service (studentServices.js) mention below:
(function () {
'use strict';
angular
.module('StudentViewer')
.factory('studService', ['$http', '$rootScope', '$location', 'CONSTANTS', StudentService]);
function StudentService($http, $rootScope, $location, CONSTANTS) {
var factory = {
getStudentList: function () {
return $http.get(CONSTANTS.WEBAPIPATH + "student/getAllStudent");
},
getStudent: function (params) {
return $http.get(CONSTANTS.WEBAPIPATH + "student/getStudentByRollNo/" + params);
},
addStudent: function (params) {
return $http.get(CONSTANTS.WEBAPIPATH + "student/addNewStudent", params);
},
updateStudent: function (params) {
return $http.get(CONSTANTS.WEBAPIPATH + "student/UpdateStudentProfile", params);
},
deleteStudent: function (paramr) {
return $http.get(CONSTANTS.WEBAPIPATH + "student/deleteStudentRecord/" + params);
}
};
return factory;
}
})();
I have define my CONSTANTS.WEBAPIPATH in a separate JS(Constant.js) file as mention below:
(function () {
angular
.module('StudentViewer')
.constant('CONSTANTS', {
'WEBAPIPATH': 'http://localhost:2751/api/',
'MAXRECORDSPERPAGE': 15,
'STARTPAGE': 1,
'MAXPAGESTODISPLAY': 5,
'PAGENUMBERSTODISPLAYSTART': 1,
'PAGENUMBERSTODISPLAYEND': 5
});
//.run(function ($rootScope, CONSTANTS, $location) {
// $rootScope.CONSTANTS = CONSTANTS;
//});
}());
And here is my app.js file
(function () {
'use strict'
.module('StudentViewer', ['ngRoute'])
.config(Config);
function Config($httpProvider, $routeProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
$httpProvider.defaults.transformRequest = function (data) {
console.log(data);
if (data === undefined) {
return data;
}
return $.param(data);
};
$routeProvider
.when('/student', {
templateUrl: 'app/view/studentList.html',
controller: 'ListController'
})
.when('/student/create', {
templateUrl: 'app/view/add.html',
controller: 'addController'
})
.when('/student/edit/:rollno', {
templateUrl: 'app/view/edit.html',
controller: 'editController'
})
.when('/student/delete/:rollno', {
templateUrl: 'app/view/delete.html',
controller: 'deleteController'
});
}
Config.$inject = ['$httpProvider', '$routeProvider'];
})();
And finally this is my 2 Angular Controller addController.js
(function () {
'use strict';
angular
.module('StudentViewer')
.controller('addController', ['$scope', '$http', '$rootScope', 'studService', addController]);
// addController.$inject = ['$scope'];
function addController($scope, $http, $rootScope, studService) {
$scope.title = 'addController';
$scope.stud = {
rollNo: 0,
name: '',
stClass: 0,
address: '',
phone: '',
email: '',
DOB: new Date().toLocaleDateString()
};
$scope.submit = function (isvalid) {
if (!isvalid) return false;
$scope.successResponse = '';
$scope.failResponse = '';
var param = {
rollNo: 0,
name: $scope.stud.name,
stClass:$scope.stud.stClass,
address: $scope.stud.address,
phone: $scope.stud.phone,
email: $scope.stud.email,
DOB: $scope.stud.DOB
};
studService.addStudent(param).then(onSubmitSuccess, onSubmitFaliure);
};
function onSubmitSuccess(response) {
$scope.rollNo = response.data.rollNo;
}
function onSubmitFaliure(response) {
$scope.failedMessage = response.data.ExceptionMessage;
}
}
})();
This is the list Controller
(function () {
'use strict';
angular
.module('StudentViewer')
.controller('ListController',['$scope', '$http', '$rootScope', 'studService', ListController]);
//ListController.$inject = ['$scope'];
function ListController($scope, $http, $rootScope, studService, $rootParam, $location) {
$scope.title = 'ListController';
studService.getStudentList().then(onListSuccess, onListFaliur);
function onListSuccess(response) {
$scope.studs = respons.data.items;
}
function onListFaliur(response) {
$scope.failedMessage = response.data.ExceptionMessage;
}
}
})();
Here is my index.html
<!DOCTYPE html>
<html ng-app="StudentViewer">
<head>
<meta charset="utf-8" />
<title></title>
<script src="lib/angular/angular.min.js"></script>
<script src="lib/angular-resource/angular-resource.min.js"></script>
<script src="lib/angular-route/angular-route.min.js"></script>
<script src="lib/jquery/dist/jquery.min.js"></script>
<script src="lib/bootstrap/dist/js/bootstrap.min.js"></script>
<link href="lib/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<script src="app/js/app.js"></script>
</head>
<body>
<div class="container">
<h1>STUDENT AAP</h1>
<div class="col-lg-12">
<div class="col-md-3">Add Student</div>
</div>
<div ng-view>
</div>
</div>
</body>
</html>
Here is my list view page which will be called inside the index page when my application is run.
<h3>Student List</h3>
<div class="table-responsive" ng-controller="ListController">
<table class="table table-striped table-bordered">
<tr>
<th>Roll No</th>
<th>Student's Name</th>
<th>Class</th>
<th>Address</th>
<th>Phone</th>
<th>Email</th>
<!--<th>Date of Birth</th>-->
<th></th>
</tr>
<tr ng-repeat="stud in studs">
<td ng-bind="stud.rollNo"></td>
<td ng-bind="stud.name"></td>
<td ng-bind="stud.stClass"></td>
<td ng-bind="stud.address"></td>
<td ng-bind="stud.phone"></td>
<td ng-bing="stud.email"></td>
<!--<td></td>-->
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
I have set my solution multi project startup. My application is run with out any error, but showing 404 error (No page found). Anyboy can help me out to run my application.
Here is my startup.cs
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
// app.UseIISPlatformHandler();
//app.Run(async (context) =>
//{
// await context.Response.WriteAsync("Hello World!");
//});
}
// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}

Nothing happens when Angular Href is clicked

I am using Angular Routing with a webapi 2 controller.
Although the default path loads with the correct data, when I click on an item in a list containing a link to a details page, no data is loaded.
The browser shows what I believe to be the correct url (http://localhost:xxxxx/#/details/2) but the DetailsController script file is not called and no method on the webapi2 controller is called.
Here is my main page :
<div class="jumbotron">
<h1>Movies Example</h1>
</div>
#section scripts {
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/angular-route.js"></script>
<script src="~/Client/Scripts/atTheMovies.js"></script>
<script src="~/Client/Scripts/ListController.js"></script>
<script src="~/Client/Scripts/DetailsController.js"></script>
}
<div ng-app="atTheMovies">
<ng-view></ng-view>
</div>
Here is the list partial :
<div ng-controller="ListController as ctrl">
<h1>{{ctrl.message}}</h1>
<h2>There are {{ctrl.movies.length}} Movies in the Database</h2>
<table>
<tr ng-repeat="movie in ctrl.movies">
<td>{{movie.Title}}</td>
<td>
<a ng-href="/#/details/{{movie.Id}}" >Details</a>
</td>
</tr>
</table>
</div>
Here is the details partial:
<div ng-controller="DetailsController as ctrl2">
<h2>ctrl2.message</h2>
<h2>{{movie.Title}}</h2>
<div>
Released in {{movie.ReleaseYear}}
</div>
<div>
{{movie.Runtime}} minutes long.
</div>
</div>
Here is the javascript file to create the angular app:
(function () {
var app = angular.module("atTheMovies", ["ngRoute"]);
var config = function ($routeProvider) {
$routeProvider
.when("/list", { templateUrl: "/client/views/list.html" })
.when("/details/:id", { templatUrl: "/client/views/details.html" })
.otherwise(
{ redirectTo: "/list" });
};
app.config(config);
}());
Here is the javascript file to create the list controller:
(function (app) {
app.controller("ListController", ['$http', function ($http) {
var ctrl = this;
ctrl.message = "Hello World!";
ctrl.movies = [];
$http.get("/api/movie")
.success(function (data) {
ctrl.movies = data;
})
.error(function(status){
ctrl.message = status;
});
}])
}(angular.module("atTheMovies")));
Here is the javascript file to create the details controller:
(function (app) {
app.controller("DetailsController", ['$routeParams', '$http', function ($routeParams, $http) {
var ctrl2 = this;
ctrl2.message = "";
ctrl2.movie = {};
var id = $routeParams.id;
$http.get("/api/movie/" + id)
.success(function(data){
ctrl2.movie = data;
}).error(function (status) {
ctrl2.message = status;
});
}])
}(angular.module("atTheMovies")));
Finally here is the webapi2 controller
public class MovieController : ApiController
{
private MovieDb db = new MovieDb();
// GET: api/Movie
public IQueryable<Movie> GetMovie()
{
return db.Movies;
}
// GET: api/Movie/5
[ResponseType(typeof(Movie))]
public IHttpActionResult GetMovie(int id)
{
Movie movie = db.Movies.Find(id);
if (movie == null)
{
return NotFound();
}
return Ok(movie);
}
You have a typo in your route config i.e. templatUrl
.when("/details/:id", { templatUrl: "/client/views/details.html" })
should be
.when("/details/:id", { templateUrl: "/client/views/details.html" })

How to implement Infinite Scrolling for AngularJS & MVC

I created one angular JS application using MVC 4
where i created one view which renders templates in that we have one template which contains large amount of data as one lack records for that i am looking to implement Infinite Scrolling
1.index.cshtml
<div id="sidebar-left" class="span2">
<div class="nav-collapse sidebar-nav">
<ul class="nav nav-tabs nav-stacked main-menu">
<li class="navbar-brand">Talks</li>
<li class="navbar-brand">SRDNames</li>
<li class="navbar-brand">Speakers</li>
<li class="navbar-brand">Add Talk</li>
</ul>
</div>
</div>
SRDNames.cshtml
<div class="box-content">
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<tr>
<th>
SRD_NAME
</th>
<th>
CREATED_BY_USER_ID
</th>
</tr>
<tr ng-repeat="srdname in srdnames">
<td>
{{srdname.sRD_NAME}}
</td>
<td>
{{srdname.cREATED_BY_USER_ID}}
</td>
</tr>
</table>
3.eventModule.js
var eventModule = angular.module("eventModule", []).config(function ($routeProvider, $locationProvider) {
//Path - it should be same as href link
$routeProvider.when('/Events/Talks', { templateUrl: '/Templates/Talk.html', controller: 'eventController' });
$routeProvider.when('/Events/Speakers', { templateUrl: '/Templates/Speaker.html', controller: 'speakerController' });
$routeProvider.when('/Events/AddTalk', { templateUrl: '/Templates/AddTalk.html', controller: 'talkController' });
$routeProvider.when('/Events/SRDNames', { templateUrl: '/Templates/SRDNames.html', controller: 'srdnamescontroller' });
$locationProvider.html5Mode(true);
});
srdnamescontroller.js
eventModule.controller("srdnamescontroller", function ($scope, EventsService) {
EventsService.getSRDName().then(function (srdnames) { $scope.srdnames = srdnames }, function ()
{ alert('error while fetching talks from server') })
});
5.EventsService.js
eventModule.factory("EventsService", function ($http, $q) {
return {
getSRDName: function () {
// Get the deferred object
var deferred = $q.defer();
// Initiates the AJAX call
$http({ method: 'GET', url: '/events/GetSRDName' }).success(deferred.resolve).error(deferred.reject);
// Returns the promise - Contains result once request completes
return deferred.promise;
},
});
looking to implement like http://jsfiddle.net/vojtajina/U7Bz9/ in above application.. please help
Demo
There are many possible solutions. Here is one that may work for you.
Implement a scroll module that defines the following:
An infiniteScroll directive
A data service to get the scrollable data
You can use the scroll module from within your app:
HTML:
<div ng-app="app" ng-controller="ctrl">
<div infinite-scroll="items">
</div>
</div>
JS:
var app = angular.module('app', ['scroll']);
app.controller('ctrl', function($scope, dataService) {
$scope.items = [];
dataService.loadMore($scope.items, function(lastItem) {
var items = [];
var id = lastItem ? lastItem.id : 0;
for (var i = 0; i < 5; i++) {
items.push({id: id + i});
}
return items;
});
});
The dataService exposes a loadMore method that accepts an array, and a callback function to load more data. The above example loads more data by looping through 5 items, and adding to the array. But you can customize this function callback to retrieve data from another service:
var app = angular.module('app', ['scroll']);
app.controller('ctrl', function($scope, $http, dataService) {
$scope.items = [];
dataService.loadMore($scope.items, function(lastItem, done) {
var lastItemId = lastItem ? lastItem.id : '';
$http({ method: 'GET',url:'api/items/' + lastItemId})
.success(function(items) {
done(items);
});
});
});

Resources