Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ng show animate不添加动画类_Angularjs_Animation - Fatal编程技术网

Angularjs ng show animate不添加动画类

Angularjs ng show animate不添加动画类,angularjs,animation,Angularjs,Animation,使用1.3测试版,我将angular-animate.js包括在内,并将ngAnimate添加到我的模块中 我有一个html div元素,如下所示: <div class='box-show' ng-show='isHidden'>test</div> 我正在检查chrome检查器,无法看到正在添加的.ng hide add或.ng hide remove类。仅添加或删除.ng隐藏。该文档说,我们需要将webkit转换添加到要为angular设置动画的元素中,并添加必要

使用1.3测试版,我将angular-animate.js包括在内,并将ngAnimate添加到我的模块中

我有一个html div元素,如下所示:

<div class='box-show' ng-show='isHidden'>test</div>
我正在检查chrome检查器,无法看到正在添加的.ng hide add或.ng hide remove类。仅添加或删除.ng隐藏。该文档说,我们需要将webkit转换添加到要为angular设置动画的元素中,并添加必要的动画类。我补充说,那么问题出在哪里呢?(以上css仅在显示框时才进行动画制作)

我个人不喜欢在玩
ng animate
时使用默认的
.animate
类。我建议在你的
.box show
元素上抛出一个
.animate show
类,然后按照你的风格去做。看看那辆破车

我相信如果元素上没有animate类或属性,
ng animate
就不知道该做什么

CSS示例:

  .box-show {
    -webkit-transition:0.5s linear all;
    transition:0.5s linear all;
    opacity:0;
  }

  .box-show.animate-show {
    opacity:1;
  }

  .box-show.animate-show.ng-hide-add,
  .box-show.animate-show.ng-hide-remove {
    display:block!important;
  }

  .box-show.animate-show.ng-hide {
    opacity:0;
  }
HTML示例:

  <div class='box-show animate-show' ng-show='isHidden'>test</div>
测试

我也遇到了同样的问题,我通过为
ng animate

.box-show.ng-animate {
  opacity:0;
}

我不知道为什么,但它起作用了。在css中包含
ng animate
之后,Angular开始将相应的类分配给元素(
ng hide add
ng hide remove
)。

发生这种情况是因为我没有将ngAnimate注入控制器。我花了一段时间才弄明白这个相当基本的疏忽。希望这能帮助其他人

不,它不会改变任何事情。。。我认为我的代码中还有另一个问题。。。我正在通过链接调用的指令更改isHidden。但我不认为问题是。。。我在另一个元素上有一个自定义js动画。这可能是原因吗?另一个元素上的自定义JS动画通常不受影响。您是从自定义绑定调用isHidden吗?例如,
angular.element(window.bind('scroll',function(){scope.ishiden=true;})将不会被Angular捕获,除非在指令的范围更新之后运行
if(!$scope.$$phase)$scope.$apply()
。您是如何解决的?我也有同样的问题,如果你想让它和css一起工作的话,我不知道ng类到底发生了什么。尽量不要触碰内置指令。
.box-show.ng-animate {
  opacity:0;
}