2017-12-29 19 views

답변

0

편집기와 드롭 다운에는 모두 활용할 수있는 이벤트 메소드가 있습니다. 각도

: 여기에 사용할 수 있음을 과도하게 단순화 예입니다

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

@Component({ 
    selector: 'app-root', 
    templateUrl: './app.component.html', 
    styleUrls: ['./app.component.css'] 
}) 
export class AppComponent { 
    title = 'app'; 
    text1 = '<div>Hello World!</div><div>PrimeNG <b>Editor</b> Rocks</div><div><br></div>'; 
    text2: string; 

    cities = [ 
     { name: 'New York', code: 'NY' }, 
     { name: 'Rome', code: 'RM' }, 
     { name: 'London', code: 'LDN' }, 
     { name: 'Istanbul', code: 'IST' }, 
     { name: 'Paris', code: 'PRS' } 
    ]; 

    emitContentFromDropdown(e: Event) { 
     const dropDownValue = e['value']['name']; 
     this.text1 = this.text1 + '<br>' + dropDownValue; 
    } 

} 

HTML :

아마
<h3 class="first">Default</h3> 
<p-editor [(ngModel)]="text1" [style]="{'height':'320px'}"></p-editor> 

<h3 class="first">Single</h3> 
<p-dropdown [options]="cities" (onChange)="emitContentFromDropdown($event)" [(ngModel)]="selectedCity" placeholder="Select a City" optionLabel="name"></p-dropdown> 

정확히 무엇을 당신이 그것을 할 수있는 (그리고 가장 좋은 방법을하려고), 그러나 당신에게 옳은 방향으로 인도 할 수있는 모범을주고 싶었습니다. 희망이 도움이됩니다.

+0

정확히 이것은 지금까지 수행 한 작업이지만 불행히도 드롭 다운 값은 매번 새 줄에 추가됩니다./ – zto

+0

오, 생각했던 것입니다. 당신이하려고하는 것은 무엇입니까? –