1

When I compile without AoT all is fine, but when compile with AoT I get this error

ReferenceError: nameColumnHeader is not defined

I declared my ViewChild inside .ts file and inside .html file I set local variable like this <div #nameColumnHeader></div> Is there an expected way to write ViewChild when compile with AoT ?

istiti
  • 141
  • 1
  • 11
  • How did you write it? Why inside `.html`? – Günter Zöchbauer Oct 21 '16 at 09:11
  • thanks for response, I said it works when compile without AoT... I write it inside my component template AFAIK it's an .html file :) and I use it inside ngOnInit... so what is the right behavior ? because without AoT it works and with it doesn't work ! – istiti Oct 21 '16 at 09:14
  • Please post the code. Can't make sense of the comment. – Günter Zöchbauer Oct 21 '16 at 09:15
  • here you are ts : http://pastebin.com/CUKU0cMx and if you need tempalte : http://pastebin.com/fwrac4Lt and if useful when I comment this ViewChild in particular so another get me error called 'end' it's reference to sidenav from material2 lib, I don't understand all is OK without AoT, thanks for help – istiti Oct 21 '16 at 09:19
  • I don't see what you mean by "viewchild in HTML". There is a `;` missing after `@ViewChild('end') end` – Günter Zöchbauer Oct 21 '16 at 09:22
  • please apologize I edit my question I mean I declared `#nameColumnHeader ` local variable inside view, anyway it seems it works !!! But I don't understand, I was thinking semicolons in js/ts are optional, they aren't ? Why without AoT it compile ... donno – istiti Oct 21 '16 at 09:36
  • AoT has to do it's own parsing and processing of the code which can be implemented differently than in other tools. So adding the missing `;` fixed it? – Günter Zöchbauer Oct 21 '16 at 09:40
  • yes thanks this resolve, still not understand why AoT parsing doesn't add semicolons automatically, maybe missfeature, and cli error is very poor and insigifiant why this doesn't tell me "semicolumn miss" or donno – istiti Oct 21 '16 at 11:28

0 Answers0