ViewChild aren't find using AoT
- After get a 3th party lib support AoT, I succeed to compile with
ngc
no error on compilation! - I inject this 3th party lib into my project, so my project compile with CLI using
--aot
flag and no error during compilation, but when open app on navigator I get:
ReferenceError: nameColumnHeader is not defined
- This
nameColumnHeader
is aViewChild()
decorator :
@ViewChild('nameColumnHeader') nameColumnHeader: TemplateRef<any>;
Of course I have <template #nameColumnHeader...>
inside HTML. When remove this ViewChild, another get me same issue #end of material2/sidenav component ...
I don't know what is problem and by the way, why cli don't tell me what is problem when ng serve --prod --aot on my project !!!
Bundle main.js bigger using AoT
I remove all my ViewChild()
recompile with --aot
all is OK, page shown correctly, but:
When I compile using ng build --prod
the size of main.js is 1836 Ko and when compile with AoT ng build --prod --aot
the size of the main.js is : 1860Ko
IF USEFUL
UPDATE:
When use ViewChild you need use semicolons !!! it's strange we can write ViewChild without seimicolons when compiling without AOT but with AoT you need semicolons