Search code examples
angularangular6primengcolor-picker

How to trigger primeng colorpicker using a button?


Here is stackblitz link:- https://stackblitz.com/edit/angular-gtv8vo?file=src/app/app.component.html

Here, colorpicker is not opening while click of a button? How to open color pallete onclick of button?

<p-colorPicker [(ngModel)]="color"></p-colorPicker>
<button class="btn btn-primary">Add COlor</button>

Solution

  • Simple way:

    <p-colorPicker #pcp [(ngModel)]="color"></p-colorPicker>
    <button class="btn btn-primary" (click)="pcp.onInputClick()">Add Color</button>