Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度4应用程序错误:“;js:1169未捕获错误:PlatformRef没有提供程序&引用;_Javascript_Angular_Typescript_Angular Cli - Fatal编程技术网

Javascript 角度4应用程序错误:“;js:1169未捕获错误:PlatformRef没有提供程序&引用;

Javascript 角度4应用程序错误:“;js:1169未捕获错误:PlatformRef没有提供程序&引用;,javascript,angular,typescript,angular-cli,Javascript,Angular,Typescript,Angular Cli,我在尝试使用浏览器运行单页应用程序时遇到以下错误(我对chrome和safari都有相同的问题)。我正在起诉angular cli(angular 4)和typescript。我有一个独特的组件和一个独特的模块。使用主组件,我试图从后端请求一些数据 从浏览器中提出的问题: core.es5.js:1169 Uncaught Error: No provider for PlatformRef! at injectionError (core.es5.js:1169) at noProviderE

我在尝试使用浏览器运行单页应用程序时遇到以下错误(我对chrome和safari都有相同的问题)。我正在起诉angular cli(angular 4)和typescript。我有一个独特的组件和一个独特的模块。使用主组件,我试图从后端请求一些数据

从浏览器中提出的问题:

core.es5.js:1169 Uncaught Error: No provider for PlatformRef!
at injectionError (core.es5.js:1169)
at noProviderError (core.es5.js:1207)
at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._throwOrNull (core.es5.js:2649)
at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKeyDefault (core.es5.js:2688)
at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKey (core.es5.js:2620)
at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_.get (core.es5.js:2489)
at createPlatform (core.es5.js:4239)
at core.es5.js:4265
at core.es5.js:4262
at core.es5.js:4262
该错误似乎是由于以下代码行写入主模块中注入的主组件中引起的: 设res=new CalculatorCore().getMaxProfitCurrencyPath(500,dataManager.getCalculateDataStructure(“EUR”)

这里是clas CalculatorCore:

import { Currency } from "./currency";
import { Map } from 'collections/map';

export class CalculatorCore {

private inputOutputCurrency: string = "EUR";

constructor() {
}


getMaxProfitCurrencyPath( price: number, currency: Currency, steps?: number, path?: Currency[]):Map<number,string[]> {

let returningPath: Map<number, string[]> =  new Map<number,string[]>();

currency.getConvertibles().forEach((key:Currency, value:number) => {

    if (!steps) {
      steps = 2;
    } else if (steps > 0) {
      steps--;
      if (currency.getLabel() == this.inputOutputCurrency){
        path = [];
    }

      path.push(key);

      this.getMaxProfitCurrencyPath(price*value, key, steps, path);
    } else if (steps == 0 && key.getConvertibles().has(this.inputOutputCurrency)){
          path.push(key.getConvertibles().get(this.inputOutputCurrency));
          returningPath.add(key.getConvertibles().get(this.inputOutputCurrency)*price, path);
        }
      });

return returningPath;
   }
}
有人能解释这个错误吗?
谢谢,

由无效的
引导设置引起

修理
使用angular cli创建一个新项目,并将引导方式与angular的最新推荐指南进行比较。

问题似乎是由于使用集合/地图造成的。

请向我们显示您的组件代码。您是否从应用模块导入了
BrowserModule
?您好,我正在从我的应用程序模块导入BrowserModule。您还可以在主要问题中看到上面的组件代码。谢谢我正在使用angular cli创建的默认代码引导应用程序:platformBrowserDynamic();
import {Component, OnInit} from '@angular/core';
import { KrakenClient } from 'kraken-api/kraken.js';
import {DataManager} from "./data-manager";
import {CalculatorCore} from "./calculator-core";


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent implements OnInit{

  ngOnInit(): void {
   let dataManager = new DataManager();

   let res =  new CalculatorCore().getMaxProfitCurrencyPath(500, dataManager.getCalculateDataStructure("EUR"));

   console.log(res);

  }

  constructor(){
    console.log("App-component constructor")
  }

}