gurps gurps - 1 month ago 31
TypeScript Question

app.module error with finding a name

I am currently creating an angular 2 project, however I cannot get passed these two errors I am getting in my console

ERROR in [default] /Users/~/src/app/app.module.ts:35:4
Cannot find name 'SelectItem'.

ERROR in [default] /Users/~/src/app/app.module.ts:36:4
Cannot find name 'Message'.

I have added the two imports into my app.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

import {SelectItem, Message, Header} from 'primeng/primeng';

@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
SelectItem,
Message,
Header
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

Answer

http://www.primefaces.org/primeng/#/setup

According to this, you want to import the specific modules in your app.module.ts, not the components by themselves.

Try this:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

import {SelectButtonModule} from 'primeng/primeng';

@NgModule({
 declarations: [
  AppComponent,
 ],
 imports: [
  BrowserModule,
  FormsModule,
  HttpModule,
  SelectButtonModule,
 ],
 providers: [],
 bootstrap: [AppComponent]
})
export class AppModule { }

Next, you should be able to use the SelectButton in your components/templates.