Issue
I'm new to angular and I have some questions about services in angular. In some examples the documentation used **export ** before class export and in some codes it used the class with out export no Export. I would appreciated if some one help me to understand its difference completely.
I was trying to inject my service but after I imported it I got the "its not exported" error and it messed up my mind to completely understand each ones usage.
Solution
You discovered a typo in their documentation where they forgot to add the export
keyword before the class name of the service. Any time you want to use a class in another file you have to export it in order for it to be available for other files to import. Seeing that service files are intended to be shared classes you'll want to export them.
With that being said, it's not mandatory to always export your classes, interfaces, types, functions etc. You just won't be able to use them outside of the file you define them in which in some cases you may not need to use them anywhere else which is perfectly fine.
Answered By - Optiq
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.