委托句柄如何在 ionic + angularjs 中工作?
how delegate-handle work in ionic + angularjs?
能否请您告诉我在 ionic 中 delegate-handle 是如何工作的?我用代码笔做了一个演示。我想在单击按钮时将内容滚动到顶部。但是当我滚动我的内容然后按下按钮时我的代码不起作用但是我的滚动没有到达顶部为什么?
http://codepen.io/anon/pen/wavoXb
var app=angular.module('app',['ionic']);
app.controller('MainCtrl',function($scope){
$scope.scrollMainToTop = function() {
$ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
};
$scope.scrollSmallToTop = function() {
$ionicScrollDelegate.$getByHandle('small').scrollTop();
};
})
您需要在控制器中注入$ionicScrollDelegate。
app.controller('MainCtrl',function($scope,$ionicScrollDelegate){
$scope.scrollMainToTop = function() {
$ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
};
$scope.scrollSmallToTop = function() {
$ionicScrollDelegate.$getByHandle('small').scrollTop();
};
能否请您告诉我在 ionic 中 delegate-handle 是如何工作的?我用代码笔做了一个演示。我想在单击按钮时将内容滚动到顶部。但是当我滚动我的内容然后按下按钮时我的代码不起作用但是我的滚动没有到达顶部为什么? http://codepen.io/anon/pen/wavoXb
var app=angular.module('app',['ionic']);
app.controller('MainCtrl',function($scope){
$scope.scrollMainToTop = function() {
$ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
};
$scope.scrollSmallToTop = function() {
$ionicScrollDelegate.$getByHandle('small').scrollTop();
};
})
您需要在控制器中注入$ionicScrollDelegate。
app.controller('MainCtrl',function($scope,$ionicScrollDelegate){
$scope.scrollMainToTop = function() {
$ionicScrollDelegate.$getByHandle('mainScroll').scrollTop();
};
$scope.scrollSmallToTop = function() {
$ionicScrollDelegate.$getByHandle('small').scrollTop();
};