Closed puravupadhyay closed 5 years ago
Are there any errors in the browser console?
No errors in the console
Haven’t used Angular in a while so I will ask around to see if anyone else has tried using it with Angular and I will see if I can replicate it.
Ok. Thanks Adam!
If you are keen to get it working (whilst we investigate further) you could use the compiled nhsuk.min.js
file from the node_modules folder rather than ES6 modules.
You can find instructions here: https://github.com/nhsuk/nhsuk-frontend/blob/master/docs/installation/installing-with-npm.md#option-1-include-compiled-javascript
My guess would be that the header JS is trying to select the menu button before it's been rendered to the page.
Here, we are doing the select outside of the initialisation function, when it should be inside. https://github.com/nhsuk/nhsuk-frontend/blob/master/packages/components/header/header.js#L53
Just tried a bit of debugging, stepping into Header.js.
Also, I've pushed this project up: https://github.com/puravupadhyay/nhsuk-frontend-angular
Cheers
Hi @puravupadhyay
Just to let you know, I've opened a draft pull request with a potential fix for this https://github.com/nhsuk/nhsuk-frontend/pull/402 I'm just testing it out with your Angular application (and other applications) now. Also looking at potential ways we could improve our JavaScript, so if you have any advice that would be greatly appreciated.
Thanks for raising this with us, hopefully we should get it fixed soon.
Thanks @AdamChrimes for that. I tested the changed files and they're working.
Just a thought - could use the namespaces in JavaScript - not 100% confident that it will work. Will have to play-around with it a bit, I'll try and set the project up my end. I guess this is the best place to look for guidance on that: https://github.com/nhsuk/nhsuk-frontend/tree/master/docs/contributing
Cheers
Hi @puravupadhyay, we've just released version 2.0.0 of the Frontend library. With this release is the fix we mentioned above for the JavaScript variables.
I've just tested it with your Angular repo with npm install nhsuk-frontend@2.0.0
and it seems to be working. Shouldn't need to update any files just the dependency.
We're still looking at improving our JavaScript overall in the issue https://github.com/nhsuk/nhsuk-frontend/issues/408 but this should fix it in the meantime.
Thanks again for raising this issue, it will be good to keep in touch. Do you use Slack? We have a public Slack instance which may easier to share progress https://nhs-service-manual.slack.com/
@AdamChrimes The new version works! Would be great to use it in future projects.
Sure, how do I join https://nhs-service-manual.slack.com/ ? I don't think I have a Slack account.
Great thanks @puravupadhyay
You will need to create an account (its free) you can sign up with your @nhs.net email address here: https://nhs-service-manual.slack.com/signup
or if you want to use another email account provider you can use this link
You can use Slack in the browser or you can download the application. Not to worry if you're not wanting to join Slack - just a useful tool for instant message and sharing quickly.
Closing as this is fixed in version 2.0.0.
Bug Report
What is the issue?
I'm trying to use this library in an Angular project. I installed nhsuk-frontend via npm fine. I managed to import the styles and can see all the component rendering but I'm having problems with the javascript files. I imported all the modules like suggested but not able to make the Menu Toggle work. Can someone please help?
What steps are required to reproduce the issue?
What was the environment where this issue occurred?
Is there anything else you think would be useful in recreating the issue?
This is the sample code of app.component.ts file: