第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Angular DI錯誤 - EXCEPTION:無法解析所有參數(shù)

Angular DI錯誤 - EXCEPTION:無法解析所有參數(shù)

小怪獸愛吃肉 2019-08-06 14:49:30
Angular DI錯誤 - EXCEPTION:無法解析所有參數(shù)我在Angular中構(gòu)建了一個基本的應(yīng)用程序,但是我遇到了一個奇怪的問題,我不能將服務(wù)注入到我的一個組件中。它注入了我創(chuàng)建的其他三個組件中的任何一個。首先,這是服務(wù):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';import { NgClass } from '@angular/common';import { ROUTER_DIRECTIVES } from '@angular/router';import {MobileService} from '../';@Component({   moduleId: module.id,   selector: 'pm-header',   templateUrl: 'header.component.html',   styleUrls: ['header.component.css'],   directives: [ROUTER_DIRECTIVES, NgClass],})export class HeaderComponent {   mobileNav: boolean = false;   constructor(public ms: MobileService) {     console.log(ms);   }}我在瀏覽器控制臺中遇到的錯誤是:EXCEPTION:無法解析HeaderComponent的所有參數(shù):(?)。我在bootstrap函數(shù)中有服務(wù),所以它有一個提供程序。我似乎能夠毫無問題地將它注入我的任何其他組件的構(gòu)造函數(shù)中。
查看完整描述

3 回答

?
繁星點(diǎn)點(diǎn)滴滴

TA貢獻(xiàn)1803條經(jīng)驗 獲得超3個贊

從直接聲明它的文件中導(dǎo)入它而不是桶。

我不知道究竟是什么導(dǎo)致了這個問題,但我看到它多次提到(可能是某種循環(huán)依賴)。

它也應(yīng)該通過改變桶中出口的順序來修復(fù)(不知道細(xì)節(jié),但也被提到)


查看完整回答
反對 回復(fù) 2019-08-06
?
呼如林

TA貢獻(xiàn)1798條經(jīng)驗 獲得超3個贊

除了之前給出的答案之外,當(dāng)您的注射服務(wù)缺少實際@Injectable()裝飾器時,似乎也會拋出此錯誤。因此,在調(diào)試循環(huán)依賴項和導(dǎo)入/導(dǎo)出的順序之前,請檢查您的服務(wù)是否實際已@Injectable()定義。

這適用于當(dāng)前的Angular最新版Angular 2.1.0。


查看完整回答
反對 回復(fù) 2019-08-06
  • 3 回答
  • 0 關(guān)注
  • 636 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號