は@NgModuleまたはでプロバイダを定義差が何であるか@Componentと@Moduleのプロバイダを注入する際のAngular2の違いは何ですか? angular2において
@NgModule({
declarations: [
...
],
imports: [
...
],
providers: [ DataService ],
bootstrap: [AppComponent ]
})
export class AppModule { }
も
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css'],
providers : [ DataService ]
})
export class HomeComponent implements OnInit {
...
}
等@Component要素でプロバイダを定義することが可能です@成分? 2つのうちの1つを選択する必要がある場合は、プロバイダーを定義するにはどうすればよいでしょうか?