2016-11-10 52 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

後來我會告訴你我的變體 –