search

Home  >  Q&A  >  body text

angular.js - About angular2 dependency injection

Version: @angular@2.0.0

xhttp is an encapsulation service for http service.

@injectable()
export class Xhttp {
    constructor (@Inject(Http) private http: Http) {}
}

Originally, this part of the service was written under Project A, but considering reuse, it was planned to be made into a separate module. After proposing it, using npm to install the above code, an error will be reported:

No provider for Http!

This module has been introduced in the provider in the top-level module.

Please also help me take a look.

PHPzPHPz2789 days ago608

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-15 17:09:18

    Have you installed the module @angular/http?

    reply
    0
  • Cancelreply