After reviewing the Angular style guide for interfaces, I find two recommendations particularly perplexing:
The suggestion to use a class instead of an interface for services and declarables (components, directives, and pipes) leaves me puzzled.
Similarly, the advice to utilize an interface for data models is unclear.
Why should a class be preferred over an interface for certain components?
Moreover, what does it mean for an interface-class to serve as a provider lookup token in Angular dependency injection?
Is there truly no alternative to defining a service as a class in Angular?
Contrary to Angular's Tour of Heroes tutorial, where the Hero model is represented as a class, it appears that using an interface may provide some benefit:
export class Hero {
constructor(public id: number, public name: string) { }
}
Furthermore, could someone clarify the concept of an interface-class
and elaborate on the term provider lookup token
?
Examples illustrating these concepts would greatly enhance my understanding. Thank you.