看一个实际的例子:import{Component,Inject}from'@angular/core';import{Http}from'@angular/http';@Component({selector:'example-component',template:'Iamacomponent'})classExampleComponent{constructor(@Inject(Http)privatehttp){//use`this.http`whichistheHttpprovider}}此时,@Inject是指定此查找标记的手动方式,后跟小写的http参数告诉Angular分配它的
看一个实际的例子:import{Component,Inject}from'@angular/core';import{Http}from'@angular/http';@Component({selector:'example-component',template:'Iamacomponent'})classExampleComponent{constructor(@Inject(Http)privatehttp){//use`this.http`whichistheHttpprovider}}此时,@Inject是指定此查找标记的手动方式,后跟小写的http参数告诉Angular分配它的