@Injectable()
export class MyService {
constructor(private http: Http, @Inject('name') @Optional() public name?: string) {
}
When setting up my appModule, I attempted to define a provider for MyService service.
MyService,
imports: [ // importing Angular modules
HttpModule,
....,
[
{ provide: 'username', useValue: 'default' }
],
const injector = ReflectiveInjector.resolveAndCreate(
[MyService,
{
provide: 'name', useValue: 'abc'
}
]);
Unfortunately, an error occurred:
ERROR Error: No provider for Http! (MyService -> Http)