javascript - 如何将 @Gbuomprisco/ng2-tag-input 与 angular-cli 一起使用?

标签 javascript angular angular-cli ng2-tag-input

我正在使用最新版本的 @angular/cli (1.0.0-beta.32.3),并且我正在尝试使用 ng2-tag-input 。 当我启动 ngserve 命令时,出现此错误:

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 5:22 in the original .ts file), resolving symbol Ng2DropdownModule in my-project/node_modules/ng2-tag-input/dist/node_modules/ng2-material-dropdown/index.d.ts, resolving symbol TagInputModule in my-project/node_modules/ng2-tag-input/dist/modules/ng2-tag-input.module.d.ts, resolving symbol TagInputModule in my-project/node_modules/ng2-tag-input/dist/modules/ng2-tag-input.module.d.ts
webpack: Failed to compile.

知道如何解决这个问题吗?

这是我的 package.json:

{
  "name": "my-project",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor",
    "build": "ng build --aot"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "bootstrap-sass": "^3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "jquery": "^3.1.1",
    "ng2-tag-input": "^0.8.5",
    "rxjs": "^5.0.1",
    "tinymce": "^4.5.3",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-beta.32.3",
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "@types/tinymce": "^4.5.0",
    "angular-cli": "1.0.0-beta.26",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.3"
  }
}

和我的app.module.ts

import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { TagInputModule } from 'ng2-tag-input';
import { RouterModule } from "@angular/router";
import { ROUTES } from "./app.routes";
import { AppComponent } from "./app.component";

@NgModule({
  declarations: [ AppComponent ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    TagInputModule,
    RouterModule.forRoot(ROUTES, { useHash: true })
  ],
  providers: [ ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

感谢您的帮助!

最佳答案

正如 Galvan 所建议的,使用 ng2-tag-input 0.8.6 版本拯救了我的一天(谢谢!)。

npm i ng2-tag-input@0.8.6 --save

我已提交 issue这样他们就可以更新 npm 注册表

关于javascript - 如何将 @Gbuomprisco/ng2-tag-input 与 angular-cli 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42368360/

相关文章:

javascript - 如何将 jquery 插件附加到动态创建的文本框

Angular2 RC 和动态路由

twitter-bootstrap - Angular 2 : How to use bootstrap-sass with @extend and mixins in Angular-CLI?

Angular CLI 自定义生成器

android - ionic 2 : How to check current page is root page in Ionic 2?

使用 chrome web 开发人员工具的 Angular 2 CLI 项目中未显示 Typescript 文件

javascript删除对象数组的多个值

javascript - 本地服务 filepicker.io JS

javascript - onChange 在每次击键时触发

Angular 2,主要组件内的组件