Issue
Perhaps this is a dumb question to ask but I am new to front-end development and come from a backend background. Doing things as so in a java class is not threadsafe if the object created is a singleton that is shared across all threads
class{
String username;
}
In Angular what happens if we have
export class RegistrationPage implements OnInit {
firstname: string = "";
}
Are components in Angular singletons?
Solution
Generally components are not singleton. And if you declare a public
variable in a component, it can only be accessed from the files of the same module(for example html file).
But services are singleton. You can access public
variables declared in the services globally.
Is that the answer you are looking for?
Answered By - Ghonche Yqr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.