0
聲明,我是很新的primeng ...爲什麼primeng下拉列表不能觸發?
我有以下組成部分
import { Component , OnInit} from '@angular/core';
import { TimeRangesService } from './time.range.service';
@Component({
moduleId : module.id,
selector: 'time-range',
templateUrl: './time.range.component.html',
})
export class TimeRangesControl implements OnInit {
timeRanges: any[];
selectedTimeRange: any;
constructor(private timeRangeService: TimeRangesService) { }
ngOnInit() {
this.timeRangeService.get().then(res => this.timeRanges = res);
}
onChange($event) {
console.log('event');
}
}
我從來沒有叫的onChange功能。 在我的html文件,我說:
<div class="content-section implementation">
<p-dropdown
[style]="{'width': '40%', 'height': '30px'}"
onChange="onChange"
[options]="timeRanges"
[(ngModel)]="selectedTimeRange"
placeholder="Select a time range"></p-dropdown>
<p>Selected Time Range: {{selectedTimeRange ? selectedTimeRange.name : 'none'}}</p>
任何想法我做錯了嗎?