zaterdag 20 januari 2018
SASS / SCSS css compiler
npm install -g node-sass
Je kunt dan node-sass aanroepen via de commandline.
SASS / SCSS documentation.
Je kunt ook in Angular 4 sass instellen. https://scotch.io/tutorials/using-sass-with-the-angular-cli
Wat neerkomt op:
ng new my-app --style=scss
maandag 15 januari 2018
Angular : change input from component not working
Meer over change detection.
vrijdag 5 januari 2018
Cassini : This operation requires IIS integrated pipeline mode.
or IISExpress as an alternative:
https://stackoverflow.com/questions/4772092/starting-and-stopping-iis-express-programmatically/20494039#20494039
woensdag 3 januari 2018
MediaQuery: Automatically close menu with Angular and Material design
const SMALL_WIDTH_BREAKPOINT = 720;
constructor(zone: NgZone)
private mediaMatcher: MediaQueryList = matchMedia(`(max-width: ${SMALL_WIDTH_BREAKPOINT}px)`);
this.mediaMatcher.addListener(mql => zone.run(() => this.mediaMatcher = mql));
isScreenSmall(): boolean {
return this.mediaMatcher.matches;
}
In de HTML:
<mat-sidenav #sidenav class="docs-component-viewer-sidenav"
[opened]="!isScreenSmall()"
[mode]="isScreenSmall() ? 'over' : 'side'"
[fixedInViewport]="isScreenSmall()"
fixedTopGap="92">
Angular template syntax alternative writing
<some-component
[prop]="someExp"
(event)="someEvent()"
[(twoWayProp)]="someExp">
</some-component>
<video-player #player></video-player>
is the same as:
<some-component
bind-prop="someExp"
on-event="someEvent()"
bindon-twowayprop="someExp">
</some-component>
<video-player ref-player></video-player>
en
<todo-cmp
*ngFor="let t of todos; let i=index"
[model]="t" [index]="t">
</todo-cmp>
desugars into:
<todo-cmp
template="ngFor: let t of todos; let i=index"
[model]="t" [index]="i">
</todo-cmp>
desugars into:
<ng-template ngFor [ngForOf]="todos"
let-t="$implicit" let-i="index">
<todo-cmp [model]="t" [index]="i"></todo-cmp>
</ng-template>
Other example. *ngIf desugars into:
<ng-template [ngIf]="true"></ng-template>
CSS animations
http://danielcwilson.com/blog/2015/07/animations-part-1/
<script src="web-animations.min.js"></script>
<div class="pulse" style="width: 150px;">Hello world!</div>
<script>
var elem = document.querySelector('.pulse');
var animation = elem.animate({
opacity: [0.5, 1],
transform: ['scale(0.5)', 'scale(1)'],
}, {
direction: 'alternate',
duration: 500,
iterations: Infinity,
});
</script>
Angular HostListener is deprecated. Use host.
@Directive({
selector: 'button[counting]',
host: {
'(click)': 'onClick($event.target)'
}
})
export class CountClicks {
nrClicks = 0;
onClick(btn) {
console.log("bt", btn, "nr of clicks:", this.nrClicks ++);
}
}
@Component({
selector: 'app-root',
template: `<button counting>Increment</button>`
})
export class AppComponent { }
dinsdag 2 januari 2018
Angular Zone
https://blog.thoughtram.io/angular/2017/02/21/using-zones-in-angular-for-better-performance.html
https://blog.thoughtram.io/angular/2016/02/01/zones-in-angular-2.html
https://blog.kwintenp.com/how-the-hell-do-zones-really-work/