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에는 데이터를 입력하십시오. 누군가 나를 설명 할 수 있습니까?

+0

모달은 별도의 구성 요소입니까, 아니면 같은 구성 요소입니까? – silentsod

+0

별도 구성 요소, –

답변

0

당신도 할 수 모달 구성 요소가 상위 구성 요소에 포함되는 경우 EventEmitter를 사용 ->https://angular.io/docs/ts/latest/api/core/index/EventEmitter-class.html

또는 당신은 관찰 등의 주제를 반환하는 서비스를 사용할 수 있습니다 - 여기를 확인하십시오. 부모 구성 요소는 관측 가능 상태에 가입 할 수 있으며 모달은 확인시 서비스에 경고합니다. 여기에 alert.service가 어떻게 쓰여지고 사용되었는지 확인하십시오.>Angular 2: Displaying icons in navbar on authentication

관련 문제