2017-02-19 4 views
1

두 개의 하위 구성 요소가 포함 된 부모가 하나 있습니다."정의되지 않은"예외를 제공하는 템플릿 변수 호출 메서드

AppComponent 
    NotificationsComponent 
    MoveCopyComponent 

MoveCopyComponent의 값을 NotificationComponent로 내보내려고합니다. 나는 내가 NotificationComponent에서 정의되지 않은 속성을 얻을 방출 할 때마다 스크린 샷 enter image description here

<notifications #notificationsMenu role="menuitem" dropdown-item 
     [caller]="'menu'" 
     (acceptShareFromMenuEvent)="shareAcceptModal.PinItem($event)"                   
     (contentShareAccepted)="shareAcceptModal.hide()"> 
</notifications> 

에 표시된 아래 우리는 아래의 내용을 배치하는 모달 팝업 구성 요소를 선언한다.

<movecopy-item #shareAcceptModal 
    (shareAcceptedandPlaced) = "notificationItem.contentAccepted($event)"> 

</movecopy-item> 

모달 (movecopy 구성 요소)에있는 버튼을 클릭 이벤트가 나는 contentAccepted (..) 아래 내 알림 구성 요소의 방법을 실행해야하는 트리거 shareAcceptedandPlaced.

shareAcceptedandPlaced(){ 
     this.shareAcceptedandPlaced.emit(this.sharedItemPinnedInfo);  
} 

은 여기에서 일어나고있는 것은 이동-CopyItem 들어오는 구성 요소를 배치 할 수있는 선택 요소는 단순히 동안 알림 구성 요소가 들어오는 구성 요소의 모음이 포함되어 있다는 것입니다.

#shareAcceptModal은 "(shareAcceptandPlaced)"은 "notificationItem의"contentAccepted() 메소드에 대한 이벤트가 발생했을 때, 나는 다음과 같은 예외가 얻을 : 는 "정의에 contentAccepted를 호출 할 수 없습니다 위의 스크린 샷과 같이."

을 여기서 내가 뭘 잘못하고 있니?

+0

로 처리하기 myContentChanged() 메소드를 가질 수 있습니다. 나는 너의 포스트를 읽고 정확한 정보를 전하지 않는다. 나는 당신의 문제에 대한 아이디어를 얻었고 그런 상황을 겪었습니다.그러나 조금 더 많은 정보가 필요합니다. teamviewer에서 사용할 수 있습니까? – Aravind

+0

Aravind에게 감사드립니다. 몇 가지 세부 사항을 추가했습니다. TV에서는 사용할 수 없지만 Skype에서는 사용할 수 있습니다. – binDebug

답변

1

실수

  1. 당신은

    (shareAcceptedandPlaced) = "notificationItem.contentAccepted($event)" 
    
  2. 당신은 당신의 이벤트 통지의 자식이 아닌 출력() 변수를 방출하는 등의 하위 구성 요소 메소드를 호출 할 수 없습니다 shareAcceptedandPlaced()

솔루션

  1. 당신이 부모로 AppComponent을 가지고 있기 때문에, 당신은 모두 하위 구성 요소에 대한 @ViewChild() 를 사용하고

    @ViewChild(movecopyComponent) mcopyComp: movecopyComponent; 
    @ViewChild(NotificationsComponent) notificationMenu: NotificationsComponent; 
    
  2. 로 프로퍼티와 메소드하여 두 아이 컴포넌트 에 액세스 할 수 있습니다
  3. 아래로 <movecopy>에 메서드 호출을 수정

    <movecopy-item #shareAcceptModal (shareAcceptedandPlaced)="myContentChanged()"> 
    </movecopy-item> 
    
  4. ,
  5. 당신은 명확한 정보를 제공하기 위해 한 번 게시물을 수정

    myContentChanged() { 
         this.mcopyComp.properties.... 
         let temp: {...};   
         this.notificationMenu.contentAccepted(temp); 
    }