Quantcast
Channel: How does variable declaration differ between the `class` and `constructor`? - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Angel Angel for How does variable declaration differ between the...

in this case export class Component1 { constructor ( private _commonService : CommonService, private _commonServiceIndipendent:commonServiceIndipendent) { }is similar to thisexport class Component1 {...

View Article



Answer by Konstantin Dinev for How does variable declaration differ between...

As the variables are defined, they are members of the Component1 class and any instance of the Component1 class has a name and an age public members of respectively string and number types. After the...

View Article

Answer by Günter Zöchbauer for How does variable declaration differ between...

If you delcare a field outside of the constructor it's available for tools that do static analysis, like a linter or autocompletion.If you add fields in the constructor, such tools would need to...

View Article

How does variable declaration differ between the `class` and `constructor`?

I have seen an example, and I am trying to reproduce it. The name and age are declared inside the class and services ( Injectable ) added in the constructor.I'd like to know the difference between...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images