PrimeNG Growl无法绑定到'value',因为它不是'p-growl'的已知属性

时间:2017-04-08 20:31:28

标签: angular primeng

我是PrimeNG的新手,但我发现你可以用它创造美好的东西。我试图从PrimeNg建立一个咆哮但我不断收到这个错误“无法绑定到'值',因为它不是'p-growl'的已知属性”。我使用了PrimeNG的“消息”,这个工作正常,所以我不知道我做错了什么,因为另一个确实有效。

我的组件ts

import {Component, OnInit} from '@angular/core';
import {IMailModel} from '../models/mail.model';
import {MailService} from '../Services/mail.service';
import {Message} from 'primeng/primeng';


@Component({
    selector: 'coordinator-invitations',
    moduleId: module.id,
    templateUrl: 'coordinatorInvitations.component.html',
    styleUrls: ['../../assets/css/in/content.css'],
})

export class CoordinatorInvitationsComponent implements OnInit {
    listReceivers: IMailModel[];
    listSenders: IMailModel[];
    pageTitle: string = 'Uitnodigingen versturen';
    errorMessage: string;
    msgs: Message[] = [];
    msgsGrowl: Message[] = [];
    subject: string = "";
    text: string="";
    success: boolean;


    constructor(private _mailService: MailService) {

    }

    ngOnInit(): void {
        this._mailService.getMailAddresses()
            .subscribe(listSenders => this.listSenders = listSenders,
                error => this.errorMessage = <any>error);
        this.listReceivers = [];
    }

    onclick(): void {
      this.msgs=[];
      this.success=true;
      if(this.listReceivers.length===0) {
        this.msgs.push({severity:'error', summary:'Error', detail:'Er zijn geen ontvangers geselecteerd.'});
        this.success=false;
      }
      if(this.subject.length===0)
      {
        this.msgs.push({severity:'error', summary:'Error', detail:'Er is geen onderwerp opgegeven.'});
        this.success=false;
      }
      if(this.text.length===0)
      {
        this.msgs.push({severity:'error', summary:'Error', detail:'Er is geen inhoud ingegeven.'});
        this.success=false;
      }

      if(this.success===true)
      {
        this.msgsGrowl.push({severity:'success', summary:'Succes', detail:'De uitnodigingen zijn succesvol verstuurd.'});
      }
    }
}

我的组件HTML

<div id="title">
    <span>{{pageTitle}}</span>
</div>
<div id="content">
  <p-growl [value]="msgsGrowl" sticky="sticky"></p-growl>
  <p-messages [value]="msgs"></p-messages>
  <p-pickList [source]="listSenders" [target]="listReceivers" sourceHeader="Kies ontvangers" targetHeader="Ontvangers" [responsive]="true" [sourceStyle]="{'height':'300px'}" [targetStyle]="{'height':'300px'}" [showSourceControls]="false" [showTargetControls]="false">
      <ng-template let-user pTemplate="item">
        <div class="ui-helper-clearfix">
          <div style="font-size:14px;">{{user.Name}}</div>
        </div>
      </ng-template>
    </p-pickList>
   <h1>Mail</h1>
<p><u>Onderwerp:</u> <input type="text" class="form-control" [(ngModel)]="subject"/></p>
<p-editor [(ngModel)]="text" [style]="{'height':'320px'}"></p-editor>
<p style="margin-top: 10px;"><button pButton type="button" label="Versturen" icon="fa-check" iconPos="left" (click)="onclick()"></button>
</p>

我的模块

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {CoordinatorPaneelComponent} from './coordinatorPaneel.component';
import {routing} from '../app.routing';
import {CoordinatorPaneelMenuComponent} from './DesignParts/coordinatorPaneelMenu.component';
import {CoordinatorTopMenu} from './DesignParts/coordinatorTopMenu.component';
import {CoordinatorDashboard} from './Dashboard/coordinatorDashboard.component';
import {CoordinatorInternshipAssignmentsViewComponent} from './InternshipAssignments/coordinatorInternshipAssignmentsView.component';
import {CoordinatorInternshipAssignmentsComponent} from './InternshipAssignments/coordinatorInternshipAssignments.component';
import {InternshipAssignmentService} from './Services/InternshipAssignment.service';
import {CommonModule} from '@angular/common';
import {CoordinatorInternshipProposalComponent} from './InternshipProposal/coordinatorInternshipProposal.component';
import {CoordinatorInternshipProposalDetailComponent} from './InternshipProposal/coordinatorInternshipProposalDetail.component';
import {CoordinatorInternshipProposalDetailViewComponent} from './InternshipProposal/coordinatorInternshipProposalDetailView.component';
import {CoordinatorInternshipProposalViewComponent} from './InternshipProposal/coordinatorInternshipProposalView.component';
import {PopupModel} from './DesignParts/popup.model';

import {CoordinatorInvitationsComponent} from './Invitations/coordinatorInvitations.component';
import {CoordinatorInvitationsViewComponent} from './Invitations/coordinatorInvitationsView.component';

import {PopupComponent} from './DesignParts/popup.component';
import {InternshipSpecialisationFilterPipe} from './Services/internshipSpecialisation-filter.component';
import {InternshipStatusFilterPipe} from './Services/internshipStatus-filter.component';
import {CoordinatorInternshipAssignmentDetailViewComponent} from './InternshipAssignments/coordinatorAssignmentDetailView.component';
import {CoordinatorInternshipAssignmentDetailComponent} from './InternshipAssignments/coordinatorAssignmentDetail.component';
import {MailService} from './Services/mail.service';
import {FormsModule} from '@angular/forms';
import {PickListModule} from 'primeng/primeng';
import {EditorModule, SharedModule, ButtonModule, MessagesModule, GrowlModule} from 'primeng/primeng';


@NgModule({
  imports: [routing, CommonModule, BrowserModule, FormsModule,
    PickListModule,
    SharedModule,
    ButtonModule,
    EditorModule,
    MessagesModule,
    GrowlModule
  ],
  declarations: [
    CoordinatorPaneelComponent,
    CoordinatorPaneelMenuComponent,
    CoordinatorTopMenu,
    CoordinatorDashboard,
    CoordinatorInternshipAssignmentsViewComponent,
    CoordinatorInternshipAssignmentsComponent,
    CoordinatorInternshipAssignmentDetailViewComponent,
    CoordinatorInternshipAssignmentDetailComponent,
    CoordinatorInternshipProposalComponent,
    CoordinatorInternshipProposalDetailViewComponent,
    CoordinatorInternshipProposalViewComponent,
    CoordinatorInternshipProposalDetailComponent,
    InternshipSpecialisationFilterPipe,
    InternshipStatusFilterPipe,
    CoordinatorInternshipProposalDetailComponent,
    CoordinatorInternshipProposalDetailViewComponent,
    PopupComponent,
    PopupModel,
    CoordinatorInvitationsComponent,
    CoordinatorInvitationsViewComponent,

  ],
  providers: [
    InternshipAssignmentService,
    MailService
  ]
})
export class CoordinatorModule {
}

TL; DR:我的PrimeNG消息模块有效,但我的PrimeNG Growl模块不起作用

3 个答案:

答案 0 :(得分:3)

从app.module.ts中的primeng导入GrowlModule。

my_loss = tf.losses.log_loss(labels, predictions)
my_running_loss, update_op = tf.metrics.mean(my_loss)

然后将GrowlModule添加到app.module.ts的导入部分。

import { GrowlModule } from 'primeng/primeng';

注意: - 当您导入primeng / primeng时,它会在项目中带来primeng的所有api,这可能会增加您的项目的大小。

答案 1 :(得分:0)

您需要在组件中导入GrowlModule

import {GrowlModule,Message} from 'primeng/primeng';

答案 2 :(得分:-3)

服务器重启修复了这个问题,但重启后我发现当你在同一页面上使用Message and Growl组件时它会开始窃听。