Как сделать так, чтобы при прокрутке до низа страницы Ангуляр получал данные с удаленного сервера? У меня получилось сделать только на кнопку.
var app = angular.module('myApp', []);
app.config(function($httpProvider) {
//Enable cross domain calls
$httpProvider.defaults.useXDomain = true;
//Remove the header used to identify ajax call that would prevent CORS from working
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
var apiKey = 'YOUR_KEY',
nprUrl = "http://maps.yandex.ru/services/search/1.x/search.json?lang=ru-RU&origin=maps-pager",
textRequest = "купить квартиру в Москве",
skipResult = 10;
var that = this;
app.controller('MainCtrl', function($scope, $http) {
$scope.maxResult = 100;
$scope.counter = 0;
$scope.textRequest = "купить квартиру в Москве"
$scope.get = function() {
$http.jsonp(nprUrl + "&text=" +$scope.textRequest + "&results=" +$scope.maxResult+ "&skip="+skipResult+ "&callback=JSON_CALLBACK")
.success(function(result) {
console.log("Success", result);
console.log(result.features);
$scope.result = result;
$scope.features = result.features;
});
};
$(window).scroll(function(){
if ($(document).height() - $(window).height() <= $(window).scrollTop() + 50) {
that.scrollPosition = $(window).scrollTop();
}
console.log(that.scrollPosition);
$scope.get = function() {
$http.jsonp(nprUrl + "&text=" +$scope.textRequest + "&results=" +$scope.maxResult+ "&skip="+skipResult+ "&callback=JSON_CALLBACK")
.success(function(result) {
console.log("Success", result);
console.log(result.features);
$scope.result = result;
$scope.features = result.features;
});
};
});
});