Last active
May 31, 2017 09:45
-
-
Save t301000/cecc8f09105683e576599419b852c690 to your computer and use it in GitHub Desktop.
簡易計數器範例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app-counter-button [step]="-2" (changed)="change($event)"></app-counter-button> | |
{{ counter }} | |
<app-counter-button [step]="5" (changed)="change($event)"></app-counter-button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
}) | |
export class AppComponent { | |
counter = 0; | |
change(v) { | |
this.counter += v; | |
// this.counter = this.counter + v; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment