How to convert
HTML
<a-entity id="fading-cube" geometry="primitive: box" material="opacity: 1">
<a-animation attribute="material.opacity" begin="fade" to="0"></a-animation>
</a-entity>
JS
document.querySelector('#fading-cube').emit('fade');
This is my code in Angular 2 that is not working.
@ViewChild('fading-cube') fadingCubeInput: any;
fadecube(){
this.renderer.setProperty(this.fadingCubeInput.nativeElement,'emit',"fade")
}
To access your element with
@ViewChild(), you can assign a template reference variable to it:Then you can use that template variable name in code:
You should be able to call
emit('fade')after casting the HTMLElement asany: