2016-11-12 14 views
3

私はangular2 + typescriptで新しいです。そして、私はテーブル内のボタンをクリックすると確認のモーダルを実現する必要があるAngular2データをモーダルに渡す

これは、テーブル

<div style="margin-top: 10px"> 
    <table id="recruitersTable" class="table table-striped center" [ngBusy]="data"> 
     <tr> 
      <th>{{ 'RECRUITER_NAME_AND_SURNANE_COLUMN' | translate }}</th> 
      <th>{{ 'RECRUITER_CODE_COLUMN' | translate }}</th> 
      <th>{{ 'RECRUITER_ACTION_DOLUMN' | translate}}</th> 
      <th></th> 
     </tr> 
     <tr *ngFor="let recruiter of recruiters"> 
      <td>{{ recruiter.Name }}</td> 
      <td>{{ recruiter.Code }}</td> 
      <td> 
       <a class="btn btn-xs btn-default" data-target="#confirm" role="button" data-toggle="modal"> 
        <span class="glyphicon glyphicon-ban-circle"></span> 
       </a> 
      </td> 
      <td></td> 
     </tr> 
    </table> 
</div> 

これは確認モーダル

<div id="confirm" class="modal fade in" aria-labelledby="modallabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
      <button class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span></button> 
      <h3 id="modalLabael">Block recruiter</h3> 
     </div> 
     <div class="modal-body"> 
      <h3 id="modalLabael">Are you sure that you want block this recruiter?</h3> 
     </div> 
     <div class="modal-footer"> 
      <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Cancel</button> 
      <button class="btn btn-success" (click)="BlockRecruiter(recruiter.code)">Block</button> 
     </div> 
    </div> 
</div> 

であると私は機能を実装する必要がありますモーダルを確認するには「成功」をクリックしますが、別のdivのデータをクリックします。誰かが私を説明できますか?

あなたのモーダルコンポーネントを親コンポーネントに含まれている場合は、持つEventEmitterを使用することができますいずれか
+0

モーダルは別のコンポーネントですか、同じものですか? – silentsod

+0

別個の成分、 –

答えて

0

- >https://angular.io/docs/ts/latest/api/core/index/EventEmitter-class.html

それとも、観察などの対象を返すサービスを使用することができます - ここで確認してください。モダリティが確認時にサービスに警告する間に、親コンポーネントはオブザーバブルに登録できます。ここでalert.serviceがどのように書かれて使用されているかを確認してください - >Angular 2: Displaying icons in navbar on authentication

関連する問題