Primeng Button not showing label

2019-07-07 00:53发布

问题:

I have primeng button in my angular4 application.

label of the button is not displaying.Button is displaying very small without label.

<div id="main">
  <form #newJobCleanUpForm="exForm" (ngSubmit)="onSubmit(exampleForm)">

    <label class="stylelabel" for="jobNumber"><span>Job Number</span>
      <input  type="text" pInputText  class="styletext" id="jobNumber" required  [(ngModel)]="jobNumber" name="jobNumber">
      <button pButton type="button"  label="Click"></button></label>
</form>
</div>

回答1:

This issue is caused by a missing import of PrimeNG's ButtonModule.

Please add this import to the same module, your component is defined in.

import {ButtonModule} from 'primeng/primeng';

...

@NgModule({
   imports: [
      ...
      ButtonModule
   ]
   ...


回答2:

In the form i have a primeng text area and forgot to add name attribute to the text area. Primeng buttons were not displaying because of this. I corrected this mistake and everything works fine.