// テンプレートの扱い
<form id="demoForm" name="demoForm" [ngFormModel]="demoForm" (submit)="demoForm($event, demoForm)"
method="post" action="" autocomplete="off">
<h3 class="first">Demo</h3>
<p-dropdown [options]="cities" [(ngModel)]="selectedCity"></p-dropdown>
<span *ngIf="!selectedCity"> Required </span>
<button pButton [disabled]="!selectedCity" type="submit" (click)="onclick()" label="Click"></button>
</form>
// 必要なファイルをインポートする
import {Button} from 'primeng/primeng';
import {Dropdown} from 'primeng/primeng';
// クラス処理
export class MyModel {
cities: SelectItem[];
selectedCity: string;
constructor() {
this.cities = [];
this.cities.push({label:'Moscow', value:'1'});
this.cities.push({label:'Istanbul', value:'2'});
this.cities.push({label:'Berlin', value:'3'});
this.cities.push({label:'Paris', value:'4'});
}
public demoForm(event: Event, demoForm: ControlGroup): void {
event.preventDefault();
// working area //
}
}