Angular 5-Typescript:json2typescript无法运行包

时间:2018-09-12 14:50:26

标签: angular5

我已经使用npm安装了它,遵循github自述文件,但是我似乎无法加载软件包并使功能运行。

这是我使用该软件包的课程之一。

import { JsonObject, JsonProperty } from 'json2typescript';

@JsonObject('AssignmentOrganizationalUnitReference')
export class AssignmentOrganizationalUnitReference extends ReferenceBase {

@JsonProperty('OrganizationName', String)
OrganizationName: string = undefined;

@JsonProperty('Name', String)
Name: string = undefined;

@JsonProperty('Active', Boolean)
Active: Boolean = undefined;

@JsonProperty('IncludeSubUnits', Boolean)
IncludeSubUnits: Boolean = undefined;

@JsonProperty('AssignmentRoles', [AssignmentRole])
AssignmentRoles: AssignmentRole[] = undefined;

@JsonProperty('UnitId', String)
UnitId: string = undefined;

@JsonProperty('Type', OrganizationalUnitReferenceType)
Type: OrganizationalUnitReferenceType = undefined;
}

这是我的systemjs

(function (global) {
System.config({
    defaultJSExtensions: true,
    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',
        '@angular/common/http': 'npm:@angular/common/bundles/common-http.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',
        'tslib': 'npm:tslib/tslib.js',
        'ngx-infinite-scroll': 'npm:ngx-infinite-scroll/bundles/ngx-infinite-scroll.umd.js',
        'ngx-spinner': 'npm:ngx-spinner/ngx-spinner.umd.js',
        'jquery': 'Content/platform/scripts/extensions/jquery-1.7.2.js',
        'json2typescript': 'npm:json2typescript/index.js'
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
        app: {
            main: 'app/main.js',
            defaultExtension: 'js',
            meta: {
                './*.js': {
                    loader: 'systemjs-angular-loader.js'
                }
            }
        },
        rxjs: {
            defaultExtension: 'js'
        }
    }
});
})(this);

加载页面时出现错误。它正在寻找代表我要导入的文件,但找不到它们。它给了我404。.

enter image description here

1 个答案:

答案 0 :(得分:0)

我通过将其添加到systemjs.config.js中的“ packages”中来解决此问题:             json2typescript:{                 defaultExtension:'js',                 主要:“ index.js”             }