Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
Angular 带角度cli的角度4-不';找不到具有AOT的第三方提供商_Angular_Angular Cli_Angular2 Aot_Toastr - Fatal编程技术网

Angular 带角度cli的角度4-不';找不到具有AOT的第三方提供商

Angular 带角度cli的角度4-不';找不到具有AOT的第三方提供商,angular,angular-cli,angular2-aot,toastr,Angular,Angular Cli,Angular2 Aot,Toastr,我正在使用Angular cli 1.2.6构建一个小型Angular 4应用程序。在开发过程中,一切都很正常,它通过ngbuild--dist成功构建。但在运行时,找不到一个名为toastr的第三方供应商,我将其用作服务-注入时,它是未定义的。以下是我将其纳入项目的方式: in.angular-cli.json ... "scripts": [ ... "../node_modules/toastr/build/toastr.min.js" ], ... 我已在单独的

我正在使用Angular cli 1.2.6构建一个小型Angular 4应用程序。在开发过程中,一切都很正常,它通过
ngbuild--dist
成功构建。但在运行时,找不到一个名为
toastr
的第三方供应商,我将其用作服务-注入时,它是
未定义的
。以下是我将其纳入项目的方式:

in.angular-cli.json

...

"scripts": [
    ...
    "../node_modules/toastr/build/toastr.min.js"
  ],

...
我已在单独的文件中创建了注入令牌:

import {InjectionToken} from '@angular/core';
import {IToastr} from './toastr.model';

export let TOASTR_TOKEN = new InjectionToken<IToastr>('toastr');

好的,经过一些研究,我找到了解决问题的办法。那天节省下来的是导出我用来分配给提供者的
useValue
属性的变量:

import {TOASTR_TOKEN} from './common/tokens';

let toastr = window['toastr'];

...
providers: [
    ...
    {provide: TOASTR_TOKEN, useValue: toastr}
],
...
import {TOASTR_TOKEN} from './common/tokens';

export let toastr = window['toastr'];

...
providers: [
    ...
    {provide: TOASTR_TOKEN, useValue: toastr}
],

好的,经过一些研究,我找到了解决问题的办法。那天节省下来的是导出我用来分配给提供者的
useValue
属性的变量:

import {TOASTR_TOKEN} from './common/tokens';

let toastr = window['toastr'];

...
providers: [
    ...
    {provide: TOASTR_TOKEN, useValue: toastr}
],
...
import {TOASTR_TOKEN} from './common/tokens';

export let toastr = window['toastr'];

...
providers: [
    ...
    {provide: TOASTR_TOKEN, useValue: toastr}
],

我不认为它会像这样工作检查如何在Angulari中包含第三方LIB我不认为它会像这样工作检查如何在Angulari中包含第三方LIB