Angular 2错误引用服务代理-asd:18错误:(SystemJS)意外的令牌< SyntaxError:意外的令牌<

时间:2017-07-01 13:14:50

标签: angular asp.net-web-api

我很抱歉问这个愚蠢的问题。我是Angular 2的新手,并且我的应用已经消耗了API的一些问题。使用的Web API位于以下文件夹结构


['abcGAUabcGAU',
 'GAUabcGAUabcGAUabcGAUabc',
 'AUabcGAUabcGAUabcG',
 'UabcGAUabcGAUabcGAUabcGAUabcGA',
 'abcGAU',
 'GAUabcAUabcGAabcUGAGUabcAUGabcAUGU']

代理内部的代码正常工作,因为我已将这两个文件移动到app文件夹中,一切正常。如果文件在共享目录

中,我收到以下错误
- src
  - app
    - Registration
      - dashboard.component.html
      - dashboard.component.ts
  - Shared
   - service-proxies
     - service.proxies.ts
     - service-proxy.module.ts

抛出错误的行是第14行。这是我的dashboard.component.js的输出

错误在以下行中引发

Error: (SystemJS) Unexpected token <
SyntaxError: Unexpected token <
    at eval (<anonymous>)
    at Object.eval (http://localhost:51860/src/app/registration/dashboard.component.js:14:25)
    at eval (http://localhost:51860/src/app/registration/dashboard.component.js:53:4)
    at eval (http://localhost:51860/src/app/registration/dashboard.component.js:54:3)
Evaluating http://localhost:51860/src/Shared/service-proxies/service-proxies
Evaluating http://localhost:51860/src/app/registration/dashboard.component.js
Evaluating http://localhost:51860/src/app/app.module.js
Evaluating http://localhost:51860/src/main.js
Error loading http://localhost:51860/src/main.js
    at eval (<anonymous>)
    at Object.eval (http://localhost:51860/src/app/registration/dashboard.component.js:14:25)
    at eval (http://localhost:51860/src/app/registration/dashboard.component.js:53:4)
    at eval (http://localhost:51860/src/app/registration/dashboard.component.js:54:3)
Evaluating http://localhost:51860/src/Shared/service-proxies/service-proxies
Evaluating http://localhost:51860/src/app/registration/dashboard.component.js
Evaluating http://localhost:51860/src/app/app.module.js
Evaluating http://localhost:51860/src/main.js
Error loading http://localhost:51860/src/main.js

以下是浏览器中我文件的完整输出。

var service_proxies_1 = require("../../Shared/service-proxies/service-proxies");

有人可以让我知道我做错了什么。请记住,如果我将文件的位置更改为app文件夹,一切正常。请帮忙

修改

这是dahsboard.component.ts文件

    (function(System, SystemJS) {(function(require, exports, module, __filename, __dirname, global, GLOBAL) {"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require("@angular/core");
var router_1 = require("@angular/router");
var hero_service_1 = require("../hero.service");
var service_proxies_1 = require("../../Shared/service-proxies/service-proxies");
var DashboardComponent = (function () {
    function DashboardComponent(injector, _storeServiceProxy, heroService, route, router) {
        this._storeServiceProxy = _storeServiceProxy;
        this.heroService = heroService;
        this.route = route;
        this.router = router;
        this.heroes = [];
        this.var1 = route.snapshot.params['id'];
        console.log(this.var1);
    }
    DashboardComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.heroService.getHeroes()
            .then(function (heroes) { return _this.heroes = heroes.slice(1, 5); });
        this.var2 = this.var1;
        console.log(this.var2);
        this._storeServiceProxy.getStoresByShortCode("")
            .subscribe(function (result) {
            var test = result.isActive;
            var testTwo = result.isActive;
        });
    };
    return DashboardComponent;
}());
DashboardComponent = __decorate([
    core_1.Component({
        selector: 'my-dashboard, ngbd-accordion-static',
        templateUrl: "app/registration/dashboard.component.html",
        styleUrls: ["app/registration/dashboard.component.css"]
    }),
    __metadata("design:paramtypes", [core_1.Injector,
        service_proxies_1.StoreServiceProxy,
        hero_service_1.HeroService,
        router_1.ActivatedRoute,
        router_1.Router])
], DashboardComponent);
exports.DashboardComponent = DashboardComponent;
//# sourceMappingURL=dashboard.component.js.map
}).apply(__cjsWrapper.exports, __cjsWrapper.args);
})(System, System);

1 个答案:

答案 0 :(得分:0)

错误原因是引用的文件不可用。由于不可用的文件index.html内容正在加载,其中&lt;作为第一个角色。 要修复它,您必须确定文件的可用路径。

首先根据您分享的文件夹结构,更改

import { StoreServiceProxy } from '../../Shared/service-proxies/service-proxies';

import { StoreServiceProxy } from '../../Shared/service-proxies/service.proxies';

import { StoreServiceProxy } from '../../Shared/service-proxies/service-proxy.module';