删除类实例

时间:2017-02-03 23:08:49

标签: javascript angularjs instance es6-class

我正在尝试删除类的实例。

我有一个<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?

0 个答案:

没有答案