[@ .disabled] =“ true”导致控制台错误

时间:2019-03-25 14:30:21

标签: angular angular-animations

我想在某些时候禁用角度动画,因此发现  docs中的[@.disabled]="isDisabled"

所以我想像这样使用它:[@.disabled]="true"(只是为了对其进行测试),但我经常遇到错误: enter image description here

错误文本:

ERROR DOMException: Failed to execute 'setAttribute' on 'Element': '[@.s' is not a valid attribute name.
    at DefaultDomRenderer2.push.../../node_modules/@angular/platform-browser/fesm5/platform-browser.js.DefaultDomRenderer2.setAttribute (http://localhost:4200/vendor.js:134848:16)
    at AnimationRenderer.push.../../node_modules/@angular/platform-browser/fesm5/animations.js.BaseAnimationRenderer.setAttribute (http://localhost:4200/vendor.js:133467:23)
    at DebugRenderer2.push.../../node_modules/@angular/core/fesm5/core.js.DebugRenderer2.setAttribute (http://localhost:4200/vendor.js:85125:23)
    at createElement (http://localhost:4200/vendor.js:81803:22)
    at createViewNodes (http://localhost:4200/vendor.js:84036:26)
    at createEmbeddedView (http://localhost:4200/vendor.js:83983:5)
    at callWithDebugContext (http://localhost:4200/vendor.js:84997:25)
    at Object.debugCreateEmbeddedView [as createEmbeddedView] (http://localhost:4200/vendor.js:84521:12)
    at TemplateRef_.push.../../node_modules/@angular/core/fesm5/core.js.TemplateRef_.createEmbeddedView (http://localhost:4200/vendor.js:82564:38)
    at ViewContainerRef_.push.../../node_modules/@angular/core/fesm5/core.js.ViewContainerRef_.createEmbeddedView (http://localhost:4200/vendor.js:82430:35)

代码:

  <ng-container *ngIf="!something" [@.disabled]="true">
    ....
    <div [@fadingListAnimation]="otherthing">

是否缺少进口?为什么说''[@.s' is not a valid attribute name.属性是@.disabled

1 个答案:

答案 0 :(得分:2)

您必须从ng-container中删除禁用的动画,因为这些容器不会在最终的HTML页面上呈现。

您无法为不存在的物体设置动画!