What are providers in Angular2?

后端 未结 5 1960
挽巷
挽巷 2020-12-14 05:58

In the Angular2 component configuration providers is one of the keys that we could specify. How are these providers defined and what are they used for?

5条回答
  •  旧巷少年郎
    2020-12-14 07:01

    import { service_name} from '../path';
    
    @Component({
    
      selector: 'selector_name',     
      templateUrl: './html file name ',
      styleUrls: ['./css file name '],
      providers: [ ./'service_name'];
    
    })
    export class AppComponent {
    
      constructor(private Service_name: service_name) { 
        //enter code here
    }
    

提交回复
热议问题