0
我不完全理解Angular 2中的@Injectable
修饰器。即使我不使用它,服务也能正常工作。 (看下面的例子)Angular 2 - Injectable()装饰器
使用@Injectable
修饰符的目的是什么?
下面是两个例子,一个具有和一个没有Injectable
与相应plunker例子:
随着@Injectable Example1`
@Injectable()
export class AppService{
get():any[]{
return "something"
}
没有@Injectable Example2
export class AppService{
get():any[]{
return "something"
}
当然我知道使用@Injectable
装饰器的原因,fo r依赖注射,但就像我之前说过的,我完全不明白。有人可以解释吗?