我希望在面板标题栏中显示添加和删除按钮。以下代码显示没有fa-icon和标签的按钮:
<p-panel>
<p-header>
<div>
Registration Form
<button type="button" pButton icon="fa-plus" style="float:right" label="Add">
</button>
</div>
</p-header>
</p-panel>
我希望在面板标题栏中显示添加和删除按钮。以下代码显示没有fa-icon和标签的按钮:
<p-panel>
<p-header>
<div>
Registration Form
<button type="button" pButton icon="fa-plus" style="float:right" label="Add">
</button>
</div>
</p-header>
</p-panel>
你的代码运行良好,在这里。
你是否已经在应用程序中导入了font-awesome
? 如果没有,请在<head></head>
标记中添加以下内容到你的index.html
文件中。
<head>
...
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
此外,您需要将ButtonModule
和PanelModule
导入您的应用程序。
import {ButtonModule, PanelModule} from 'primeng';
@NgModule({
imports: [
...
ButtonModule,
PanelModule,
...
],
...
})
app.module.ts
文件吗? - Nehalapp.module.ts
中没有看到 import {ButtonModule, PanelModule} from 'primeng';
语句。我看到它们在 imports
中,但是如果没有导入语句,它们将无法工作。此外,你在问题中提到 pButton
在 JobCleanupComponent
中可以工作。你是否再次在该组件中导入了 primeng
模块? - Nehalimport { BrowserAnimationsModule } from '@angular/platform-browser/animations';
如果你正在使用Angular2/4,你需要在app.module.ts中添加以下导入:
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
将 pi-close 改为 fa-close 对我有用。
似乎有新旧 font awesome 图标。它们必须这样使用:
class="pi pi-xxx" or class="fa fa-xxx"
你的示例代码中存在一些结构错误。我已经为你创建了一个 plnkr。
http://plnkr.co/edit/myrBq9tv4iNRNd6v6bhT?p=preview
<p-panel>
<p-header>
<div>Registration Form
<button type="button" pButton icon="fa-plus" style="float:right" label="Add"></button>
<button type="button" class="ui-button-danger" pButton icon="fa-minus" style="float:right" label="Delete"></button>
</div>
</p-header>
</p-panel>
您不能同时使用图标和标签。请尝试以下代码:
<button type="button" pButton icon="fa-plus" style="float:right"></button>
另外,从 primeng/button 导入 ButtonModule 是必须的。