Skip to content

Commit

Permalink
perf(led): using Attribute for data binding
Browse files Browse the repository at this point in the history
using Attribute for data binding to skip change detection and improve performence
  • Loading branch information
xmlking committed Sep 23, 2018
1 parent 1fce1af commit 751c7a3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libs/led/src/lib/led.component.ts
@@ -1,4 +1,4 @@
import { Component, HostBinding, Input, OnInit } from '@angular/core';
import { Attribute, Component, HostBinding, Input, OnInit } from '@angular/core';

@Component({
selector: 'ngx-led',
Expand All @@ -12,12 +12,15 @@ export class LedComponent implements OnInit {
blink = false;
@Input()
speed = 1000;
@Input()
size = '24px';
public size = '24px';
// @HostBinding('class.active') @Input() active: boolean = false;
constructor() {}
constructor(@Attribute('size') public readonly _size: string) {}

ngOnInit() {}
ngOnInit() {
if (this._size) {
this.size = this._size;
}
}

onClick() {
this.blink = !this.blink;
Expand Down

0 comments on commit 751c7a3

Please sign in to comment.