Use following code to toggle button
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
@Component({
selector: 'my-app',
template: `
<div>
<button *ngIf='toggleButton' (click)='toggleButton = false'>Button One</button>
<button *ngIf='!toggleButton' (click)='toggleButton = true'>Button Two</button>
</div>
`,
})
export class App {
name:string;
toggleButton: boolean: true; // Flag to toggle your button toggling its value on click of button
constructor() {
this.name = `Angular! v${VERSION.full}`
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…