什么是getelementbyid在角度2中的equevalant

时间:2018-02-05 09:28:48

标签: javascript angular

javascript代码......

<div>
<canvas #layout width="800" height="600">this is not working</canvas>
code here...
</div>

<script>
function myFunction() {
document.getElementById("layout")
}

角度很小 app.component.html ...

<canvas #layout width="800" height="600">this is not working</canvas>

... app.component.ts

@ViewChild('layout') canvas;
 ngOnInit() {

  const _canvas = this.canvas.nativeElement;
  ....
  }

0 个答案:

没有答案