2016-03-03 43 views
-1

我下面这个https://github.com/rpocklin/angular-scroll-animate但我在控制台得到一个错误:指令:属性必须指定一个功能

Error: Directive: angular-scroll-animate 'when-visible' attribute must specify a function.

的index.html

 <section ng-controller="Section1Controller" > 
      <div class="container" when-visible="animateElementIn" when-not-visible="animateElementOut" class="hidden"> 
      <h3 class="section-title">{{titresection}}</h3> 
      <div class="line-section"></div> 
      <div class="section-thumb"><img ng-src="../assets/images/avatar.jpg"> 
       <p class="section-contenue">{{paragraphe}}</p> 
      </div> 
      </div> 
     </section> 

controller.html

apps.controller('Section1Controller', function ($scope) { 

     $scope.titresection="Développeur frontend & backend"; 
     $scope.image='../assets/images/avatar.jpg'; 
     $scope.lefttitle=" 2016"; 
     $scope.paragraphe="éveloppeur frontend, qui développe des sites vitrines sous WordPress et des dernières techniques web : HTML5/CSS3, jQuery, jQuery UI,NodeJs,AngularJs."; 

    $scope.animateElementIn = function($el) { 
    $el.removeClass('hidden'); 
    $el.addClass('animated fadeInUp'); // this example leverages animate.css classes 
    }; 

    $scope.animateElementOut = function($el) { 
    $el.addClass('hidden'); 
    $el.removeClass('animated fadeInUp'); // this example leverages animate.css classes 
    }; 
/* 

    }); 
+0

你看该项目的[问题日志](https://github.com/rpocklin /角滚动动画/问题/ 7)? – JDB

回答

1

更新 我已经添加了jsfiddle。见here。它工作正常。你的模板看起来很好。其他地方肯定有错误。我希望你已经包含了animate.css。如果您可以共享代码的jsfiddle/plunker,它将帮助我们解决问题。

我浏览了angular-scroll-animate的代码,发现when-visiblewhen-not-visible实际上是对函数的引用。

controller: ['$scope', function(scope) { 
     if (!scope.whenVisible || !angular.isFunction(scope.whenVisible())) { 
      throw new Error('Directive: angular-scroll-animate \'when-visible\' attribute must specify a function.'); 
     } 

     if (scope.whenNotVisible && !angular.isFunction(scope.whenNotVisible())) { 
      throw new Error('Directive: angular-scroll-animate \'when-not-visible\' attribute must specify a function.'); 
     } 
     else if (!scope.whenNotVisible) { 
      scope.whenNotVisible = function() { 
      return angular.noop; 
      }; 
     } 

     if (scope.delayPercent) { 

      var delayPercent = parseFloat(scope.delayPercent); 

      if (!angular.isNumber(delayPercent) || (delayPercent < 0 || delayPercent > 1)) { 
      throw new Error('Directive: angular-scroll-animate \'delay-percent\' attribute must be a decimal fraction between 0 and 1.'); 
      } 
     } 
    }], 

下面将无法正常工作 您需要使用

<div class="container" when-visible="animateElementIn()" when-not-visible="animateElementOut()" class="hidden"> 

因为它们的功能

+0

不工作,请参阅https://github.com/rpocklin/angular-scroll-animate了解我需要什么 – sabrine

+0

@sabrine除了“香蕉”之外,“不工作”是绝对最不有用的东西。请描述什么不起作用。 – JDB

+0

@JDB我说我使用这个https://github.com/rpocklin/angular-scroll-animate,当我运行我的应用程序它不显示我的数据,并得到错误错误:指令:角度滚动动画'时“可见”属性必须指定一个函数。 – sabrine

相关问题