我正在尝试删除类的实例。
我有一个<button>
标记,其中包含一个事件监听器类方法remove
:
<msg-item>
<span>username: {{this.username}}</span>
<p>message: {{this.message}}</p>
<button ng-click="$ctrl.remove()">delete</button>
<msg-item>
<msg-item>
<span>username: {{this.username}}</span>
<p>message: {{this.message}}</p>
<button ng-click="$ctrl.remove()">delete</button>
<msg-item>
<msg-item>
<span>username: {{this.username}}</span>
<p>message: {{this.message}}</p>
<button ng-click="$ctrl.remove()">delete</button>
<msg-item>
班级:
class msgItemCtrl{
constructor(){
this.username = "johndoe";
this.message = "hello world";
}
remove(){
console.log('FIRING: Class Method (remove)');
delete this;
}
}
问题:如何从界面中删除类的实例以及关联的HTML?