简体   繁体   English

使用角度2和素数

[英]Working with angular 2 and prime ng

I am trying to include primeng library into my project with 我试图将primeng库包含到我的项目中

package.json 的package.json

"dependencies": {
    "@angular/common": "~2.2.3",
    "@angular/compiler": "~2.2.3",
    "@angular/core": "~2.2.3",
    "@angular/forms": "~2.2.3",
    "@angular/http": "~2.2.3",
    "@angular/platform-browser": "~2.2.3",
    "@angular/platform-browser-dynamic": "~2.2.3",
    "@angular/router": "~3.2.3",
    "@types/jquery": "^2.0.34",
    "angular2-highcharts": "^0.4.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.1.1",
    "ng2-bootstrap": "^1.4.0",
    "ng2-bs3-modal": "^0.10.4",
    "ng2-popover": "0.0.12",
    "primeng": "^2.0.4",
    "rxjs": "5.0.0-rc.4",
    "toastr-ng2": "^3.2.5",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },

angular-cli.json 角cli.json

 "styles": [
            "./app/app.scss",
            "../node_modules/primeng/resources/primeng.min.css",
            "../node_modules/primeng/resources/themes/omega/theme.css",
            "../node_modules/font-awesome/scss/font-awesome.scss"
        ],
        "scripts": [
            "../node_modules/jquery/jquery.min.js",
            "../node_modules/tether/dist/js/tether.min.js",
            "../node_modules/bootstrap/dist/js/bootstrap.min.js"
        ],

app.module.ts app.module.ts

import {SpinnerModule} from 'primeng/primeng';

NgModule NgModule

@NgModule({
  imports: [
    AboutModule,
    ApiHelperModule,
    CoreModule,
    HomeModule,
    PostModule,
    StyleGuideModule,
    ToDoModule,
    BrowserModule,
    FormsModule,
    HttpModule,
    SpinnerModule,
    RouterModule.forRoot(CoreRoutes)
  ],
  declarations: [
    AppComponent
  ],
  providers: [
    {
      provide: AuthHttp,
      useFactory: getAuthHttp,
      deps: [Http]
    }
  ],
  schemas:[CUSTOM_ELEMENTS_SCHEMA],
  bootstrap: [AppComponent]
})

about.component.ts about.component.ts

import { Component, OnInit, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SpinnerModule } from 'primeng/primeng';

@Component({
  selector: 'app-about',
  templateUrl: './about.component.html'
})
export class AboutComponent implements OnInit {
  val:any;
  constructor() { 
    this.val = 25;

  }

  ngOnInit() {
  }
}

about.component.html about.component.html

 <p-spinner [(ngModel)]="val"></p-spinner>

There is no error in compilation, but my console throws the error as 编译时没有错误,但我的控制台将错误抛出

在此输入图像描述

I assume like this is becos of version mismatch, but i couldnt figure the primeng version list that matches to angular 2 我认为这是因为版本不匹配,但我无法确定与角度2匹配的primeng版本列表

Your help is highly appreciated. 非常感谢您的帮助。

You have to include ReactiveFormsModule 您必须包含ReactiveFormsModule

imports: [ 
   ReactiveFormsModule 

],

Update : you did not add AboutComponent to declarations 更新:您没有将AboutComponent添加到声明中

 declarations: [
    AppComponent, AboutComponent
  ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM