Receiving errors while implementing an angular service

4 views
Skip to first unread message

Eric Downey

unread,
Jul 19, 2019, 2:26:37 AM7/19/19
to Angular and AngularJS discussion
Hi Folks,

I've been a .Net developer for years and decided to take the plunge into node/typescript/angular/ionic.  I'm working on a pwa for my board gaming club and was pretty happy with my progress until I tried to implement a service in order to move out the embeded arrays I was using to populate several drop downs in a form I had created.  So I used the angular cli and created a boiler plate service, moved my arrays into the class, made them private and created functions to return copies of the arrays.  Granted I'm doing all of this based off a youtube video I'm watching but it all seemed very cut and dry.  When I viewed the page in chrome I started seeing a bunch of errors and wasn't sure where to look for examples or how to fix them.

Here's the first one and it looked like it was referring to something in content_script_bundle.js:
Uncaught TypeError: c.querySelectorAll is not a function at MutationObserver.<anonymous>

And then I got this one referring to my html page:
ERROR Error: formControlName must be used with a parent formGroup directive.  You'll want to add a formGroup  directive and pass it an existing FormGroup instance (you can create one in your class).

It sounds like I forgot to add something to the app files to reference the service?  I did add a reference to it in the constructor of page.ts file and mad the service calls in ngOnInit to populate the variables that hold the arrays to be displayed in the drop downs.

I can certainly paste in code here but even though this is a really small project angular projects are kinda huge - a lot of plumbing going on but I'm very excited about the potential so learn I must.  If it would help to paste in code or attach files by all means let me know and I will do so.

I'm using the latest greatest of angular, ionic, node, typescript and vs code.

Sander Elias

unread,
Jul 20, 2019, 12:26:16 AM7/20/19
to Angular and AngularJS discussion
Hi Eric,

Can you put your project on stackBlitz? That way I can help you.
Sound like that you moved too much into your service. 

Regards
Sander
Reply all
Reply to author
Forward
0 new messages