简体   繁体   English

在Angular 2中为非GUI类使用哪种类型的类装饰器?

[英]What type of Class Decorator to use for a non-GUI Class in Angular 2?

I want to take advantage of Object Oriented principles and group my code into classes. 我想利用面向对象的原理,并将我的代码分为几类。 However, my classes frequently have dependencies on either @angular libraries or services that I have created. 但是,我的类经常依赖于我创建的@angular库或服务。

Using the new operator is out because many libraries fail without the DI framework. 之所以无法使用new运算符,是因为许多库如果没有DI框架就会失败。

What is the proper way to make a plain old class that depends on @angular libraries? 制作依赖@angular库的普通旧类的正确方法是什么?

也许可以肯定地说,如果我根据@angular依赖项计划一个类,我应该只使用@Injectable()并将其创建为服务吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM