繁体   English   中英

Angular 4 + ngx-datatable:@ swimlane / ngx-datatable 404(未找到)

[英]Angular 4 + ngx-datatable: @swimlane/ngx-datatable 404 (Not Found)

我是Angular的新手。 我运行它来启动我的项目: git clone https://github.com/angular/quickstart appName

我将其更新为Angular 4,一切应该很好。 这是运行ng -v的输出:

@angular/cli: 1.1.3
node: 6.11.0
os: darwin x64
@angular/common: 4.0.3
@angular/compiler: 4.0.3
@angular/core: 4.0.3
@angular/forms: 4.0.3
@angular/http: 4.0.3
@angular/platform-browser: 4.0.3
@angular/platform-browser-dynamic: 4.0.3
@angular/router: 4.0.3
@angular/cli: 1.1.3

我需要一个高度可配置的表模块ngx-datatable是一个不错的选择。 我按照这些页面上的说明进行操作:

https://swimlane.gitbooks.io/ngx-datatable/introduction/installing.html https://swimlane.gitbooks.io/ngx-datatable/introduction/getting-started.html

我可以运行npm start并加载应用程序,但是我的浏览器遇到了一个中断应用程序的错误:

GET http://localhost:3006/@swimlane/ngx-datatable 404 (Not Found)

在此处输入图片说明

这是我的app.module.ts

import { NgModule, CUSTOM_ELEMENTS_SCHEMA }      from '@angular/core';
import { BrowserModule }                         from '@angular/platform-browser';
import { HttpModule }                            from '@angular/http' ;
import { NgxDatatableModule }                    from '@swimlane/ngx-datatable';

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

@NgModule({
  imports:      [ BrowserModule, HttpModule, NgxDatatableModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }

package.json的一部分

"dependencies": {
    "@angular/common": "~4.0.0",
    "@angular/compiler": "~4.0.0",
    "@angular/core": "~4.0.0",
    "@angular/forms": "~4.0.0",
    "@angular/http": "~4.0.0",
    "@angular/platform-browser": "~4.0.0",
    "@angular/platform-browser-dynamic": "~4.0.0",
    "@angular/router": "~4.0.0",
    "angular-in-memory-web-api": "~0.3.0",
    "systemjs": "0.19.40",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.1.3",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.46",
    "canonical-path": "0.0.2",
    "concurrently": "^3.2.0",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "^2.2.0"
  }

我的systemjs.config.js

(function (global) {
  System.config({
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      'app': 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs':                      'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js',
        meta: {
          './*.js': {
            loader: 'systemjs-angular-loader.js'
          }
        }
      },
      rxjs: {
        defaultExtension: 'js'
      }
    }
  });
})(this);

花了整整一天的时间在工作,而我在同一地点。 我的设置有什么问题?

system.config.js下行添加到您的system.config.js >映射中

'@swimlane/ngx-datatable': 'npm:@swimlane/ngx-datatable/release/index.js',

我不确定在package.json中未引用ngx数据表时会如何加载。 它在您的依赖项中需要此:

“ @ swimlane / ngx-datatable”:“ ^ 9.3.0”

安装然后运行。

暂无
暂无

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

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