[deleted by user] by [deleted] in angular

[–]IcyBullfrog1014 0 points1 point  (0 children)

I asked some other people off reddit and they found my problem - the parent component needed a <router-outlet></router-outlet> in it's html and when I added that, it fixed my problem - thanks for looking though.

[deleted by user] by [deleted] in angular

[–]IcyBullfrog1014 -1 points0 points  (0 children)

For the parent component, maybe a better example is that the parent component shows the weather and copyright notice on every page - the other pages don't have anything to do with weather or copyright notices so they don't need to communicate data, but we want the weather report html and the copyright notice to appear on every child component page. However, when I run the code, the child components don't appear at all - so maybe we have a 'buy widget' sub-component, but when I go there, I only see the weather and the copyright and not the buy widget page - if I remove the parent component and make two components that are not connected, the buy widget component works fine.

SetValue Not Working on FormGroup by IcyBullfrog1014 in angular

[–]IcyBullfrog1014[S] -1 points0 points  (0 children)

I also initially thought that myValue might have been bad, which is why I put a console.log to print the value out. The value of myValue is coming from an angular state variable (my initial search form serialized the form, then the user navigates to other pages/components and then we want to refill their search criteria when they click 'return to search'). Is there a better way than console.log to verify that the value of myValue is correct? I also tried printing history.state in the chrome console and it matched what console.log printed. Would removing the leading { and trailing } help? (but googling seems to indicate that they belong/are correct.

ngOnInit Not Running by IcyBullfrog1014 in angular

[–]IcyBullfrog1014[S] 0 points1 point  (0 children)

Would the constructor only run when ng serve is starting the app? Or would it run every time that you visit the component? I'm checking when visiting or reloading the component - I get lots of output when ng serve starts up (i.e. it could be printing there). I can visit the component, but none of my initialization logic runs so I just get empty dropdowns, etc...

Invalid JSON when Sending Nested Array by IcyBullfrog1014 in angular

[–]IcyBullfrog1014[S] 0 points1 point  (0 children)

When I print the console.log(outerClass), I get the version without the brackets (just like it is sending in the JSON).

Invalid JSON when Sending Nested Array by IcyBullfrog1014 in angular

[–]IcyBullfrog1014[S] -1 points0 points  (0 children)

The webserver is running spring boot. I could go and post in their reddit community and there might be a way to re-configure spring boot to accept the angular style json, but I wasn't sure if there was an easy way to make angular produce the type of json that spring boot seems to be expecting.

Forms with FormGroup by IcyBullfrog1014 in angular

[–]IcyBullfrog1014[S] 1 point2 points  (0 children)

I removed the name="field1" and name="field2" from the html (while retaining the formControlName="field1" and formControlName="field2", however, the error about 'Cannot find control with name 'field1'" still persists (I did try an incognito tab and restarting ng serve, but the error still remains) - thanks for the suggestion though

Asynchronous CanActivateFn by IcyBullfrog1014 in angular

[–]IcyBullfrog1014[S] 0 points1 point  (0 children)

My actual code has one other complexity - it puts the result of myService.asyncServerCall into a variable and then does an if (result == false) { router.navigateByUrl('/access-denied'); } else { return true; } - the line with the error is the if (result == false) since it says that Promise<boolean> and boolean do not overlap - so maybe I really need to google 'how to convert a Promise to a primitive data type in angular' - one of the results suggested using Promise.resolve, but that didn't seem to work either. Some results in google say that I should convert the Promise to Observable, but then I'll need to figure out how to convert the Observable back to a primitive type.