@jurisicmarko
http://angularjs.blogspot.co.at/2016/12/ok-let-me-explain-its-going-to-be.html
backwards compatible with 2.x.x for most applications.
smaller and faster
improved *ngIf and *ngFor
updated Typescript version
<div *ngIf="userList | async as users; else loading">
<user-profile *ngFor="let user of users; count as count" [user]="user">
</user-profile>
<div>{{count}} total users</div>
</div>
<ng-template #loading>Loading...</ng-template>
npm install
@angular/common@latest @angular/compiler@latest
@angular/compiler-cli@latest @angular/core@latest
@angular/forms@latest @angular/http@latest
@angular/platform-browser@latest
@angular/platform-browser-dynamic@latest
@angular/platform-server@latest
@angular/router@latest @angular/animations@latest typescript@latest --save
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
before
after
$ ng build
$ rm -rf node_modules
$ npm install
$ ng build -w
Angular 4.0.0
Angular 2.4.0
Animations from core package are marked as deprecated (compiles but fails at runtime)
import { Component, OnInit, Input, ElementRef } from "@angular/core";
import { trigger, state, style, transition, animate, keyframes, group } from "@angular/animations";
Components and templates must be converted to executable JavaScript by the Angular compiler.
Just-in-time in browser is the standard approach during development
Runtime performance penalty
AOT can improve performance and help catch template errors early
https://angular.io/docs/ts/latest/cookbook/aot-compiler.html
$ ng build --prod
export function bootstrapPds(configService: ConfigService): () => Promise<BootstrapConfig> {
return () => configService.loadWithPromise(PATH_CONFIG_BOOTSTRAP);
}
@NgModule({
imports: [ CommonModule ]
})
export class CoreModule {
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
if(parentModule) {
throw new Error(`CoreModule is already loaded. Import in the AppModule only`);
}
}
static forRoot(preferenceServiceConfig: PreferenceServiceConfig): ModuleWithProviders {
return {
ngModule: CoreModule,
providers: [
ApiGatewayService,
AuthGuard,
DepsRdepsService,
{
provide: PreferenceServiceConfig,
useValue: preferenceServiceConfig
},
{
provide: APP_INITIALIZER,
useFactory: bootstrapPds,
deps: [ ConfigService, Http ],
multi: true
},
SnapshotService,
ValidationService
]
}
}
}
2.4.0
4.0.0
Development build
Production build
var StatsWriterPlugin = require("webpack-stats-plugin").StatsWriterPlugin;
// ...
getTargetConfig(webpackConfigOptions) {
var statWriter = new StatsWriterPlugin({
chunkModules: true,
fields: null,
filename: "stats.json" // Default
});
switch (webpackConfigOptions.buildOptions.target) {
case 'development':
var data = webpack_configs_1.getDevConfig(webpackConfigOptions);
if(typeof(data.plugins) === 'undefined') {
data['plugins'] = [];
}
data.plugins.push(statWriter);
return data ;
// ...
node ./node_modules/webpack-bundle-analyzer/src/bin/analyzer ./dist/stats.json