Используйте ViewChild и вызывайте их onInputClick()
.
В AppComponent добавьте @ViewChild и импортируйте компонент ColorPicker.
import { Component, ViewChild } from '@angular/core';
import { ColorPicker} from 'primeng/colorpicker';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
@ViewChild('colorpicker') colorpicker: ColorPicker;
name = 'Angular';
color:any;
clickButton(): void {
this.colorpicker.onInputClick()
}
}
Шаблон:
<p-colorPicker #colorpicker [(ngModel)]="color"></p-colorPicker>
<button class="btn btn-primary" (click)="clickButton()">Add COlor</button>
Рабочий пример