2016-11-10 50 views
1

我开始学习angular2 +打字稿,并试图找到像ng-really-message,ng-really-click(在Angularjs中)当我点击删除按钮时。有人能提出我最好的办法吗?并链接到文档。 P.S.我使用asp.net核心,.NET的核心Angular2手稿确认popover

回答

0

您可以轻松地实现这个,而不需要外部模块/指令:

import { Component } from '@angular/core'; 
@Component({ 
    selector: 'app-root', 
    template: ` 
    <a (click)="confirm('Are you ready?', takeaction)">Delete Me</a> 
    ` 
}) 
export class AppComponent { 
    confirm(msg, fn){ 
    let result = confirm(msg) 
    if (result) { 
     fn() 
    } 
    } 

    takeaction(){ 
     console.log('Taking Action!!') 
    } 
} 
+0

可我们对这一解决办法讨论? –

+0

你试过这个吗?让我知道你有什么问题。 – Kaptrain

+0

后来我会告诉你我的变体 –