【问题标题】:Angularjs : ng-class not workingAngularjs:ng-class 不工作
【发布时间】:2016-03-15 12:17:05
【问题描述】:

我正在使用 animate.css

HTML

    <div ng-init="animate=false" when-visible="animate=true" ng-class="{animate: visible}">
  <h3 class="section-title" ng-class="{animate: fadeIn}">{{titresection}}</h3>
</div>

但当我滚动任何想法时不起作用?

【问题讨论】:

  • 试试这个

    {{titresection}}

  • @hadiJZ 我的控制台指令出错:angular-scroll-animate 'when-visible' 属性必须指定一个函数。并且不显示值(titiresection)
  • 你是否注入了 angular-scroll-animate 依赖项?
  • @hadiJZ 是的,我已经注入了!

标签: angularjs angularjs-directive directive ng-class


【解决方案1】:

刚刚检查了 when-visible 指令,在你的控制器中,你需要在你的作用域上创建一个函数,然后在 when-visible 指令中引用它。

控制器:

$scope.showSection = function(){
    $scope.animate = true;
}

页面:

<div ng-init="animate=false" when-visible="showSection" ng-class="{'visible': animate}">
    <h3 class="section-title" ng-class="{'fadeIn': animate}">{{titresection}}</h3>
</div>

【讨论】:

  • 然后创建一个 plunkr 或其他东西。
猜你喜欢
  • 2015-08-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-18
  • 2014-11-24
  • 2016-02-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多