更新时间:2023-01-15 20:25:46
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
@Component({
selector: 'my-app',
template: `
<div>
<a href = "#" (click) = "on()">{{value}}</a>
</div>
`,
})
export class App {
value = "View";
toogle = true;
on(val:boolean){
//either this
this.value = (!this.toogle)?"View":"Hide";
this.toogle = !this.toogle;
//or this
this.value = (this.value == "View")?"Hide":"View"; // and remove toogle
}
}
@NgModule({
imports: [ BrowserModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}
PLUNKER链接- https://plnkr.co/edit/Wt8s8HSraBsnx9PzgDrA?p=preview
PLUNKER LINK - https://plnkr.co/edit/Wt8s8HSraBsnx9PzgDrA?p=preview