angular2-aot

Angular2 : Dynamic component creation : AOT Compilation

依然范特西╮ 提交于 2019-11-30 08:55:16
Below is my initial code to create dynamic module : protected createComponentModule(componentType: any) { @NgModule({ imports: [ ComponentModule ], declarations: [ componentType ], }) class RuntimeComponentModule { } return RuntimeComponentModule; } While I am going to implement AOT on below code it throw me error: No NgModule metadata found for 'RuntimeComponentModule' I found solution of it some Articals by change below code and my error gone away: default class RuntimeComponentModule { } But new error is raised it say: Modifiers cannot appear here It not allowed me to decorate @NgModule

Using Rollup for Angular 2's AoT compiler and importing Moment.js

谁说胖子不能爱 提交于 2019-11-29 23:57:10
I'm trying to follow the official AoT guide for Angular 2, and I'm using Moment.js in my application. Moment.js is on my packages.json file, and I'm using version 2.15.0. I've been importing it like this so far: import * as moment from 'moment'; But when I get to the part where I have to run rollup, I end up with the following error: Cannot call a namespace ('moment') Which appears to be related to the way I import moment according to this . So, how am I supposed to do this? I can't seem to import moment any other way. If I use import moment from 'moment' I get the compile error External

Angular 2 AOT vs JIT

陌路散爱 提交于 2019-11-29 14:34:50
I was just reading Angular 2 AOT documentation and a few questions poped up The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup? The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng

Angular2 AOT with Lazy loading Can't resolve [path to lazy module].ngfactory.ts

强颜欢笑 提交于 2019-11-29 04:22:11
I am trying to convert an App that was already working with Lazy loaded modules into AOT. I am using the @ngtools/webpack toolkit to compile the AOT code, however I am getting into an error that Angular cant find the Lazy loaded module's code as it seems. ERROR in ./src/ngfactory async Module not found: Error: Can't resolve '/Library/WebServer/Documents/envato-teams/src/ngfactory/src/app/components/container/projects.ngfactory.ts' in '/Library/WebServer/Documents/envato-teams/src/ngfactory' @ ./src/ngfactory async @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js @ ./src

Using Rollup for Angular 2's AoT compiler and importing Moment.js

南楼画角 提交于 2019-11-28 20:59:27
问题 I'm trying to follow the official AoT guide for Angular 2, and I'm using Moment.js in my application. Moment.js is on my packages.json file, and I'm using version 2.15.0. I've been importing it like this so far: import * as moment from 'moment'; But when I get to the part where I have to run rollup, I end up with the following error: Cannot call a namespace ('moment') Which appears to be related to the way I import moment according to this. So, how am I supposed to do this? I can't seem to

Property 'X' is private and only accessible within class 'xyzComponent'

邮差的信 提交于 2019-11-28 16:36:32
问题 I'm trying to build angular2 application for production for that I'm following this blog. After my ngc successful compilation when the tsc compilation takes place it generates below error shown in the image: After searching for a while I found this blog which explains the problem in "The context property" section which I'm not able to understood properly may be it give some good idea to you that what's happening wrong. basically when we're making a variable private we're getting "ERROR:

window is undefined when used as useValue provider with Angular 4 AoT

假如想象 提交于 2019-11-28 12:30:33
When Angular 4.0.2 application is compiled ahead-of-time, and the provider is defined as useValue import { OpaqueToken, Provider } from '@angular/core'; export const windowToken = new OpaqueToken('window'); export const windowProvider = { provide: windowToken, useValue: window }; and used like @NgModule({ providers: [windowProvider], ... }) export class AppModule {} it compiles ok but results in window being undefined when injected as constructor(@Inject(windowToken) window) { window.navigator... } The error is thrown on bootstrapping: TypeError: Cannot read property 'navigator' of undefined

Angular 2 AOT vs JIT

时光毁灭记忆、已成空白 提交于 2019-11-28 09:02:35
问题 I was just reading Angular 2 AOT documentation and a few questions poped up The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup? 回答1: The documentation clearly favours AOT over JIT and mentioned all the good

Angular2 AOT with Lazy loading Can't resolve [path to lazy module].ngfactory.ts

北城以北 提交于 2019-11-27 22:21:32
问题 I am trying to convert an App that was already working with Lazy loaded modules into AOT. I am using the @ngtools/webpack toolkit to compile the AOT code, however I am getting into an error that Angular cant find the Lazy loaded module's code as it seems. ERROR in ./src/ngfactory async Module not found: Error: Can't resolve '/Library/WebServer/Documents/envato-teams/src/ngfactory/src/app/components/container/projects.ngfactory.ts' in '/Library/WebServer/Documents/envato-teams/src/ngfactory' @

Angular 2 Ahead-of-Time compiler: must I make all class properties public?

丶灬走出姿态 提交于 2019-11-27 13:36:28
Angular 2 rc 6 , typescript 2 , node 4.5.0 , npm 2.15.9 on Windows 7 I'm trying to move from Just-in-Time to Ahead-of-Time compilation and I'm relying on these resources: Angular 2 - Ahead-of-time compilation how to https://github.com/angular/angular/tree/master/modules/@angular/compiler-cli#angular-template-compiler I understand that I need to run the compiler ngc to generate ngfactory.ts files, and that I need to change main.ts to use platformBrowser instead of platformBrowserDynamic to bootstrap. I've hit a roadblock though and don't know how to proceed. 1. I've confirmed that the App runs