Angularjs在另一个控制器中调用指令

时间:2014-05-13 15:52:47

标签: angularjs events resize call directive

    abcModule.directive('resize', function ($window) {
        return function (scope, element) {alert('ad');
        var w = angular.element($window);
        scope.getWindowDimensions = function () {
            return { 'h': w.height(), 'w': w.width() };

        };
        scope.$watch(scope.getWindowDimensions, function (newValue, oldValue) {
            scope.windowHeight = newValue.h;
           //scope.windowWidth = newValue.w;
          // alert('cal');
            scope.wrapHeight = $('#wrapper').height();
            scope.calcHeight = scope.windowHeight - scope.wrapHeight;           
            if(scope.calcHeight > 80){
                scope.isScroll = false;
            }
            else{
                scope.isScroll = true;
            }
            scope.style = function () {
                return { 
                    'height': (newValue.h - 100) + 'px',
                    //'width': (newValue.w - 100) + 'px' 
                };
            };

        }, true);
        w.bind('resize', function () {
            scope.$apply();
        });
    }
})

现在我想在一个基于某种条件的另一个函数里面调用上面的resize方法,任何人都可以帮我吗???

0 个答案:

没有答案