Daniel
Daniel

Reputation: 1755

Uncaught (in promise): Error: No provider for Credentials?

What does it mean?

I have import:

import {Credentials} from '../_models/credentials/credentials.model';

And constructor:

constructor(private router: Router,
private credential: Credentials){
}

Upvotes: 0

Views: 204

Answers (2)

FAISAL
FAISAL

Reputation: 34673

You cannot inject a model in the constructor. Define credential as a class variable.

import {Credentials} from '../_models/credentials/credentials.model';
// ... 
//
private credential: Credentials;
// ... ...
//
constructor(private router: Router){ }

Upvotes: 1

Suraj Rao
Suraj Rao

Reputation: 29614

You cant inject a model class in the constructor. It needs to be @Injectable() and set as a provider to be used by Angular's DI.

Change your constructor to:

constructor(private router: Router)

Upvotes: 2

Related Questions