2017-03-02 20 views
0

Ng2Bs3ModalModuleを使用してコンポーネントをポップアップ表示しています。ここでは、このために、私は、以下の方法を使用しています:角度2のコンポーネントに値を渡す

従う

<modal #modal> 
    <modal-header [show-close]="true"> 
     <h4 class="modal-title">Update Job Service</h4> 
    </modal-header> 
    <modal-body> 
     <app-job-service-edit></app-job-service-edit> 
    </modal-body> 
</modal> 

はその後、私は(以下model.openを使用して、このモデルを開くと、私はマスターコンポーネントのテンプレートを作成する)イベント(クリック)で。

<button type="button" class="flat btn-danger" name="table_records" (click)="modal.open()">EDIT</button> 

ここで、上記のボタンをクリックしてコンポーネントに値を渡す必要があります。どうすればいいですか?

ありがとうございます。

+0

あなたがsemicolumnを使用し、スコープに値を設定することができます。 モーダルコンポーネントがアクセスできる 'EDIT ' – Sravan

+0

'

+0

投稿で私の回答を確認してください http://stackoverflow.com/questions/42385142/pass-data-from-one-component-to-another-and-reflect-in-view/42386408#42386408 –

答えて

0

セミコラムを使用して別の関数呼び出しを使用して値を送信することができます。ここ

(click)="modal.open();(click)="test('hello')

<button type="button" class="flat btn-danger" name="table_records" (click)="modal.open();(click)="test('hello')">EDIT</button> 

成分の例です。

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'app-root', 
    styles: [` 
    .app { 
     display: block; 
     text-align: center; 
     padding: 25px; 
     background: #f5f5f5; 
    } 
    `], 
    template: ` 
    <div class="app"> 
     <a (click)="test('hello')">Click me to alert</a> 
    </div> 
    ` 
}) 
export class AppComponent { 


    test(value): void { 
    console.log(value) 
    alert(value) 
} 

} 

Here is a workinf DEMO

+0

@ nifCody、私の答えをチェックしてください。 – Sravan

関連する問題