Javascript 这3个Angular2命令导入的是什么?

Javascript 这3个Angular2命令导入的是什么?,javascript,angularjs,angular,angular2-providers,Javascript,Angularjs,Angular,Angular2 Providers,我正在使用ES6 JavaScript学习Angular2。具体地说,我正试图从整个应用程序的根JavaScript文件开始绘制依赖项链,即有人能解释一下下面三行的boot.js到底导入了什么吗 import { CORE_PROVIDERS } from './app/core'; import { AUTH_PROVIDERS } from './app/auth'; import { POSTS_PROVIDERS } from './app/posts'; 当我在上面的GitHub链接

我正在使用ES6 JavaScript学习Angular2。具体地说,我正试图从整个应用程序的根JavaScript文件开始绘制依赖项链,即有人能解释一下下面三行的
boot.js
到底导入了什么吗

import { CORE_PROVIDERS } from './app/core';
import { AUTH_PROVIDERS } from './app/auth';
import { POSTS_PROVIDERS } from './app/posts';
当我在上面的GitHub链接中导航到
'./app/core'
'./app/auth'
'./app/posts'
目录时,这些目录中有太多嵌套文件,我不清楚上面三个命令到底传递给三个
..提供程序
变量的是什么。请其他人解释一下好吗

boot.js
的完整代码是:

import './shim';
import 'rxjs/add/operator/map';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { FORM_PROVIDERS, LocationStrategy, HashLocationStrategy } from '@angular/common';
import { HTTP_PROVIDERS } from '@angular/http';

import { AppComponent } from './app/core/components/app/app.component';
import { APP_ROUTES_PROVIDER } from './app/core/app.routes';
import { CORE_PROVIDERS } from './app/core';
import { AUTH_PROVIDERS } from './app/auth';
import { POSTS_PROVIDERS } from './app/posts';

if (ENVIRONMENT === 'production') {
  enableProdMode();
}

bootstrap(AppComponent, [
  FORM_PROVIDERS,
  HTTP_PROVIDERS,

  APP_ROUTES_PROVIDER,
  AUTH_PROVIDERS,
  POSTS_PROVIDERS,
  CORE_PROVIDERS,

  { provide: LocationStrategy, useClass: HashLocationStrategy },
  { provide: 'ENVIRONMENT', useValue: ENVIRONMENT }
]);
当你有一个

import { Something } from './one/two';
它将查找由
two
文件夹中的
index
文件导出的
Something
标识符


在您的情况下,当位于
/client/boot.js的文件

import { CORE_PROVIDERS } from './app/core';
import { AUTH_PROVIDERS } from './app/auth';
import { POSTS_PROVIDERS } from './app/posts';
第一个从
/client/app/CORE/index.js
,查找导出的
CORE\u提供者的标识符:

如您所见,它只是“重新导出”其他提供者,这些提供者本身存在于其他文件中

第一个在,等等


顺便说一下,使用
索引
文件是一种很好的做法,当您有

import { Something } from './one/two';
它将查找由
two
文件夹中的
index
文件导出的
Something
标识符


在您的情况下,当位于
/client/boot.js的文件

import { CORE_PROVIDERS } from './app/core';
import { AUTH_PROVIDERS } from './app/auth';
import { POSTS_PROVIDERS } from './app/posts';
第一个从
/client/app/CORE/index.js
,查找导出的
CORE\u提供者的标识符:

如您所见,它只是“重新导出”其他提供者,这些提供者本身存在于其他文件中

第一个在,等等



顺便说一下,使用
索引
文件是一种很好的做法,在Angular2样式指南中也有建议。

*\u提供者
导出对于Angular2来说是一种常规,可以将多个相关提供者保持在单个常量下(AngularJS模块的粗略对应项)


这些不是Angular 2依赖项,而是应用程序依赖项。可以逐个跟踪它们。

*\u提供者
导出是Angular 2的常规输出,用于将多个相关提供者保持在单个常量下(AngularJS模块的粗略对应项)


这些不是Angular 2依赖项,而是应用程序依赖项。可以逐个跟踪这些问题。

此页面应处理您的所有疑问:感谢您和+1以透彻和清晰的答案教育我们。此页面应处理您的所有疑问:感谢您和+1以透彻和清晰的答案教育我们。