この愚かな質問にはお詫び申し上げます。私はAngular 2を初めて使っていて、自分のアプリが消費したAPIに関するいくつかの問題を抱えています。消費のWeb APIは、私はappフォルダの中にあるもののファイルの両方を移動してきたし、すべてが正常に動作してプロキシの内部角度2のエラー参照サービスproxy-asd:18エラー:(SystemJS)予期しないトークン<SyntaxError:予期しないトークン<
- src
- app
- Registration
- dashboard.component.html
- dashboard.component.ts
- Shared
- service-proxies
- service.proxies.ts
- service-proxy.module.ts
コードが正しく動作し、以下のフォルダ構造の上に座っています。ファイルが共有ディレクトリ内にあるかどうか、私は次のエラーを取得しています
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
それがエラーを投げている行は、ここではライン14で
誤りがある私のdashboard.component.js出力され次の行にスローされます
var service_proxies_1 = require("../../Shared/service-proxies/service-proxies");
以下は、ブラウザからの私のファイルの完全な出力です。
(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);
私が間違っていることを教えてください。私がアプリケーションフォルダにファイルの場所を変更すると、すべてうまく動作することを覚えておいてください。
EDITここ
がdahsboard.component.tsがエラーのために
import { Component, Injector, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { Hero } from '../hero';
import { HeroService } from '../hero.service';
import { StoreServiceProxy } from '../../Shared/service-proxies/service-proxies';
@Component({
selector: 'my-dashboard, ngbd-accordion-static',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
private var1: string;
private var2: string;
heroes: Hero[] = [];
constructor(
injector: Injector,
private _storeServiceProxy: StoreServiceProxy,
private heroService: HeroService,
private route: ActivatedRoute,
private router: Router
) {
this.var1 = route.snapshot.params['id'];
console.log(this.var1);
}
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
this.var2 = this.var1;
console.log(this.var2);
this._storeServiceProxy.getStoresByShortCode("")
.subscribe(result => {
var test = result.isActive;
var testTwo = result.isActive;
});
}
}
に
を変更、共有フォルダ構造に基づいて開始するには
角度のjsファイルの代わりにtsファイルを貼り付けます。私はあまりにも役立つコードスニペットを投稿することができます –