2016-10-22 125 views
0

我需要通过这个 - >https://github.com/vimalavinisha/angular2-google-chart角2错误:(SystemJS)XHR错误(404未找到)

我跟每一个step.But我碰到这个错误给谷歌图表添加到我的项目SystemJs.I已经找到了一些答案(2-3个月),但他们并没有为我工作。(角2)

这是我的package.json

{ 
    "name": "angular-quickstart", 
    "version": "1.0.0", 
    "scripts": { 
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ", 
    "lite": "lite-server", 
    "postinstall": "typings install", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "typings": "typings" 
    }, 
    "licenses": [ 
    { 
     "type": "MIT", 
     "url": "https://github.com/angular/angular.io/blob/master/LICENSE" 
    } 
    ], 
    "dependencies": { 
    "@angular/common": "~2.1.0", 
    "@angular/compiler": "~2.1.0", 
    "@angular/core": "~2.1.0", 
    "@angular/forms": "~2.1.0", 
    "@angular/http": "~2.1.1", 
    "@angular/platform-browser": "~2.1.0", 
    "@angular/platform-browser-dynamic": "~2.1.0", 
    "@angular/router": "~3.1.0", 
    "@angular/upgrade": "~2.1.0", 
    "angular-in-memory-web-api": "~0.1.5", 
    "bootstrap": "^3.3.7", 
    "core-js": "^2.4.1", 
    "reflect-metadata": "^0.1.8", 
    "rxjs": "5.0.0-beta.12", 
    "systemjs": "0.19.39", 
    "zone.js": "^0.6.25" 
    }, 
    "devDependencies": { 
    "concurrently": "^3.0.0", 
    "lite-server": "^2.2.2", 
    "typescript": "^2.0.3", 
    "typings":"^1.4.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', 
     'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api', 
    }, 
    // packages tells the System loader how to load when no filename and/or no extension 
    packages: { 
     app: { 
     main: './main.js', 
     defaultExtension: 'js' 
     }, 
     rxjs: { 
     defaultExtension: 'js' 
     }, 
     'angular2-in-memory-web-api': { 
     main: './index.js', 
     defaultExtension: 'js' 
     } 
    } 
    }); 
})(this); 

tsConfig.json ---

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false 
    } 
} 

最后app.module.ts

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { AppComponent } from './app.component'; 
import { GoogleChart } from 'angular2-google-chart/directives/angular2-google-chart.directive'; 

@NgModule({ 
    imports: [ BrowserModule ,GoogleChart], 
    declarations: [ AppComponent ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { } 

这是我得到的错误 - >错误加载http://localhost:3000/angular2-google-chart/directives/angular2-google-chart.directive为“angular2-google-图表/指令/ angular2-google-chart.directive

我找不到任何可行的答案,我已经失去了很多小时这个错误。

回答

0

我由我自己解决它。我已经创建了自己的指令并从angular2-google-chart.diretive.ts文件复制粘贴源代码。它对我来说是唯一的工作方式。

0

正如我看你分享它的示例systemjs.config.js仍然缺少mappackagesdirectives属性。

它下面的样子从GitHub的文件https://github.com/vimalavinisha/angular2-google-chart/blob/master/systemjs.config.js

var map = { 
    ... 
    'directives' : 'directives/' 
    }; 

    // packages tells the System loader how to load when no filename and/or no extension 
    var packages = { 
    ... 
    'directives':{ defaultExtension: 'js' } 
    }; 
+0

但错误保持不变。 – gamal

+0

您应该为node_modules文件夹旁边的指令文件夹以及为此库定义的脚本 – Chandermani

相关问题