我有输入控件:
<input id="someID" class="form-control" type="text" name="SomeData"
data-ng-model="vm.SomeData">
当用户向下滚动到此控件时,我需要初始化值vm.SomeData
。我是棱角分明的新人,所以不确定是否会出现像ControlDisplayed&#39;
答案 0 :(得分:0)
//html
<input id="someID" when-scrolled="vm" class="form-control" type="text" name="SomeData" data-ng-model="vm.SomeData">
//try this directive
app.directive("whenScrolled", function(){
return {
restrict: 'A',
link: function(scope, elem, attrs){
// we get a list of elements of size 1 and need the first element
raw = elem[0];
// we load more elements when scrolled past a limit
elem.bind("scroll", function(){
if(raw.scrollTop+raw.offsetHeight+5 >= raw.scrollHeight){
scope.vm.name = 'Nainish Modi';
// we can give any function which loads more elements into the list
scope.$apply(attrs.whenScrolled);
}
});
}
}
});