Tag: angular2 di

Angular 2 DI错误 – EXCEPTION:无法parsing所有参数

我已经在Angular 2中构build了一个基本的应用程序,并遇到了一个奇怪的问题,我无法将服务注入到其中一个组件中。 它会把它们注入到我创build的其他三个组件中。 对于初学者来说,这是服务(这是非常基本的,因为我只是现在正在testing的东西): import { Injectable } from '@angular/core'; @Injectable() export class MobileService { screenWidth: number; screenHeight: number; constructor() { this.screenWidth = window.outerWidth; this.screenHeight = window.outerHeight; window.addEventListener("resize", this.onWindowResize.bind(this) ) } onWindowResize(ev: Event) { var win = (ev.currentTarget as Window); this.screenWidth = win.outerWidth; this.screenHeight = win.outerHeight; } } 而它拒绝使用的组件: import { Component, } from '@angular/core'; […]