[英]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){
}
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. 它必须为
@Injectable()
并设置为Angular DI所使用的提供程序。
Change your constructor to: 将构造函数更改为:
constructor(private router: Router)
You cannot inject a model in the constructor. 您不能在构造函数中注入模型。 Define
credential
as a class variable. 将
credential
定义为类变量。
import {Credentials} from '../_models/credentials/credentials.model';
// ...
//
private credential: Credentials;
// ... ...
//
constructor(private router: Router){ }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.