`${new Date().getFullYear() - 2012} years with Angular`
@ContentChild(selector, {read})
@ContentChild(selector)
import { ReflectiveInjector} from '@angular/core';
import { MyService } from './my.service';
const injector =
ReflectiveInjector.resolveAndCreate([MyService]);
myService = injector.get(MyService);
componentInstance.injector
const injector =
Injector.resolveAndCreate([MyService]);
const childInjector =
injector.resolveAndCreateChild([MyService]);
childInjector.get(MyService) !== injector.get(MyService)
live conding
Token
Recipe |
{
}
InjectionToken<UserService>(‘UserService_TOKEN’, {
providedIn: ‘root’
factory: () => new UserService()
});
new in 6:
migration:
ExpressionChangedAfterItHasBeenCheckedError
Cases:
Solution:
taken from angular performance checklist
Template syntax, Dependency injection, Content projection, Structural directives, Lifecycle hooks, Pipes..
--experimentalIvy
SEO
First screen
Social friendly preview
npm packages
prepare client part
prepare server part
create server
AngularCli + ng-packagr
$ ng add @angular/pwa
What is Security?
Authorization based on JWT
JSON Web Token
Can you spot security issue here?
export class TokenInterceptor implements HttpInterceptor {
constructor(public auth: AuthService) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({
setHeaders: {
Authorization: `Bearer ${this.auth.getToken()}`
}
});
return next.handle(request);
}
}
Sanitization out of box:
bypassSecurityTrust*
$save_text = str_replace('script', 'span', $text);
<ScRiPt>/* bad things happen here */</ScRiPt>
<INPUT TYPE="IMAGE" src="javascript:/* ... */;">
<imgsrc="xss.png" onerror="/* bad things happen here */">
npm audit
95% of HTTPS servers vulnerable to trivial MITM attack
good news for browser support