anglejsを使用しています。1.5.8、グループモジュールを使用してグループとしてコンポーネント名を作成しました。同じモジュールのディレクティブをスクロールの名前のコンポーネントとして作成します。 必要ですloadmoregroupsであるコンポーネント関数を呼び出してapiを呼び出して、bootomでスクロールするグループを増やします。外側のディレクティブからangleコンポーネント関数を呼び出す方法
angular.module('group', []).
component('group', {
templateUrl: '/djangotemplates/private/group/list.html',
controller: function(
$cookies,
$http,
$location,
$scope,
Flash,
$animate,
Group,
$timeout,
$rootScope
){
$rootScope.loadMoreGroups =function()
{
alert("loadmore");
}
}
}).directive('scroll', function() {
return {
restrict: 'A',
link: function(rootScope, element, attrs, $window, $scope, $document) {
var bind = element.bind('tbody');
var raw = element[0];
angular.element(bind).on("scroll", function() {
//console.log('in scroll mode');
if (raw.scrollTop + raw.offsetHeight >= raw.scrollHeight) {
**rootScope.loadMoreGroups();** //unable to call this `enter code here`function
}
});
}
};
});
のベストプラクティスは、機能とrootScopeを使用しないことです。もっと見る:http://stackoverflow.com/questions/32761540/why-using-rootscope-with-functions-is-not-recommended –