在Angular 2+中编写代码
单击<ul><li></li></ul>
中的按钮打印*
例如。
点击1-输出为*
点击2-输出为**
点击3-输出为***
仅在触发点击事件后添加'*':
HTML
<p>{{ title }}</p>
<button (click)="addStar()">Add star</button>
TS
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
title = '*';
addStar() {
this.title += '*';
}
}