私はAngular2を勉強していますが、bind()
とprovide()
の違いは何ですか?私のアプリケーションでは、私は違いを見つけることができないので、どの違いを使用するかについてより良い決定をすることが何であるか不思議です。現時点で最新バージョンのを使用しています。Angular2:beta17バインドとアンギュラ2の差の差
例バインド:
import { bootstrap } from 'angular2/platform/browser';
import { ROUTER_PROVIDERS } from 'angular2/router'
import { LocationStrategy, HashLocationStrategy } from 'angular2/platform/common';
import { bind } from 'angular2/core';
// Main Component
import { AppComponent } from './app.component';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
bind(LocationStrategy).toClass(HashLocationStrategy)
]);
例はを提供:
import { bootstrap } from 'angular2/platform/browser';
import { ROUTER_PROVIDERS } from 'angular2/router'
import { LocationStrategy, HashLocationStrategy } from 'angular2/platform/common';
import { provide } from 'angular2/core';
// Main Component
import { AppComponent } from './app.component';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(LocationStrategy, { useClass: HashLocationStrategy })
]);