Loiane Groner
Java + JavaScript/HTML5 developer • Web/Angular GDE • Microsoft MVP • author @PacktPub More decks available at: https://www.slideshare.net/loianeg
Loiane Groner
ng build --prod --source-map --vendor-source-map
@Component({
selector: 'app-key-value',
template: `
<div *ngFor="let curso of cursos">
<ul>
<li *ngFor="let obj of curso | keyvalue">
{{ obj.key }}: {{ obj.value }}
</li>
</ul>
</div>
`
})
export class KeyValueComponent {
cursos = [
{ id: '1', nome: 'Angular'},
{ id: '2', nome: 'Java'},
];
}
@Component({
selector: 'app-key-value',
template: `
<div *ngFor="let curso of cursos">
<ul>
<li *ngFor="let obj of curso | keyvalue:cursosComparator">
{{ obj.key }}: {{ obj.value }}
</li>
</ul>
</div>
`
})
export class KeyValueComponent {
cursos = [
{ id: '1', nome: 'Angular'},
{ id: '2', nome: 'Java'},
];
cursosComparator(a: any, b: any) {
if (a.key === b.key) {
return 0;
}
return a.key > b.key ? -1 : 1;
}
}
imports: [
RouterModule.forRoot(routes, {
scrollPositionRestoration: 'enabled'
})
]
RouterModule.forRoot(routes, {
malformedUriErrorHandler:
(error: URIError, urlSerializer: UrlSerializer, url: string) => {
// console.log(error);
console.log(url);
return urlSerializer.parse('/url-invalida');
}
})
RouterModule.forRoot(routes, {
urlUpdateStrategy: 'eager', // 'deferred'
})
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
// encapsulation: ViewEncapsulation.Emulates, // padrao
// encapsulation: ViewEncapsulation.Native, // v0
// encapsulation: ViewEncapsulation.ShadowDom, // v1
})
By Loiane Groner
Novidades Angular v6.1
Java + JavaScript/HTML5 developer • Web/Angular GDE • Microsoft MVP • author @PacktPub More decks available at: https://www.slideshare.net/loianeg