2017-10-14 3 views
0

cockpit.component.ts. . . .... . .... . . . ..... . . . .... ......... ....... ......... ......... . ... ... ...... .... . .... . 나는 다음과 같은 오류가 발생하는 이유 ... 오류 TypeError : _co.onBlueprintAdded가 함수가 아닙니다.

import {Component, EventEmitter, OnInit, Output} from '@angular/core'; 
 

 
@Component({ 
 
    selector: 'app-cockpit', 
 
    templateUrl: './cockpit.component.html', 
 
    styleUrls: ['./cockpit.component.css'] 
 
}) 
 
export class CockpitComponent implements OnInit { 
 
    @Output() serverCreated = new EventEmitter<{serverName: string, serverContent: string}>(); 
 
    @Output() blueprintCreated = new EventEmitter<{serverName: string, serverContent: string}>(); 
 
    newServerName = ''; 
 
    newServerContent = ''; 
 
    constructor() { } 
 

 
    ngOnInit() { 
 
    } 
 
    onAddServer() { 
 
    this.serverCreated.emit(
 
     {serverName: this.newServerName, 
 
     serverContent: this.newServerContent 
 
     }); 
 
    } 
 

 
    onAddBlueprint() { 
 
    this.blueprintCreated.emit(
 
     {serverName: this.newServerName, 
 
     serverContent: this.newServerContent 
 
     }); 
 
    } 
 
}

는 사람이 설명 할 수 있습니까? 나는 각도의 초보자이다.

콘솔에서

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

 
@Component({ 
 
    selector: 'app-root', 
 
    templateUrl: './app.component.html', 
 
    styleUrls: ['./app.component.css'] 
 
}) 
 
export class AppComponent { 
 
    serverElements = [{ 
 
    type: 'server', 
 
    name: 'Testserver', 
 
    content: 'Just a Test!!' 
 
    }]; 
 

 

 
    onServerAdded(serverData: {serverName: string, serverContent: string}) { 
 
    this.serverElements.push({ 
 
     type: 'server', 
 
     name: serverData.serverName, 
 
     content: serverData.serverContent 
 
    }); 
 
    } 
 

 
    onBlueprintAdded(blueprintData: {serverName: string, serverContent: string}) { 
 
    this.serverElements.push({ 
 
     type: 'blueprint', 
 
     name: blueprintData.serverName, 
 
     content: blueprintData.serverContent 
 
    }); 
 
    } 
 
}
<div class="container"> 
 
    <app-cockpit 
 
    (serverCreated)="onServerAdded($event)" 
 
    (blueprintCreated)="onBlueprintAdded($event)" 
 
    ></app-cockpit> 
 
    <hr> 
 
    <div class="row"> 
 
    <div class="col-xs-12"> 
 
    <app-server-element 
 
     *ngFor="let serverElement of serverElements" 
 
     [element]="serverElement" 
 
    ></app-server-element> 
 
    </div> 
 
    </div> 
 
</div>

오류 app.component.ts : 아직도 내가 질문을 게시하기 전에 몇 가지 물건을 쓸 필요가 나와 함께

AppComponent.html:2 ERROR TypeError: _co.onBlueprintAdded is not a function 
    at Object.eval [as handleEvent] (AppComponent.html:4) 
    at handleEvent (core.es5.js:12023) 
    at callWithDebugContext (core.es5.js:13493) 
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13081) 
    at dispatchEvent (core.es5.js:8615) 
    at core.es5.js:10783 
    at SafeSubscriber.schedulerFn [as _next] (core.es5.js:3647) 
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:238) 
    at SafeSubscriber.next (Subscriber.js:185) 
    at Subscriber._next (Subscriber.js:125) 

+0

'cockpit.component.ts'에서 데이터를 생성하는 방법을 보여주는 코드를 제공 할 수 있습니까? – Andresson

+0

삽입했습니다 –

+0

질문 헤더에 질문과 다른 오류가 있습니까? 무엇 이니? 문제를 보여주는 데모 (plunker, stackblitz?)를 만드시겠습니까? – Alex

답변

1

다시 서비스를 다시 실행하십시오. 새로운 번들을 만들 것입니다.

+0

내 문제 였어. –

관련 문제