{"id":2793,"date":"2023-06-22T15:05:26","date_gmt":"2023-06-22T15:05:26","guid":{"rendered":"https:\/\/salientsoft.co.uk\/?p=2793"},"modified":"2023-06-22T15:05:26","modified_gmt":"2023-06-22T15:05:26","slug":"angular-dynamic-routing-between-angular-elements-aka-web-components","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=2793","title":{"rendered":"Angular &#8211; Dynamic Routing between Angular Elements aka Web Components"},"content":{"rendered":"\n<p>Following on from my previous post on dynamic routing fundamentals, the ability to route dynamically across angular elements, i.e. to use the router to route to a dynamically loaded angular element, seems to be a sticking point.<\/p>\n<p>Previously, I developed a web components example where a &#8216;fabric&#8217; component was responsible for dynamically creating web components and displaying them. This did not use angular routing, but dynamically added them to the dom based on menu selections or url parameters. Subsequently, I wanted to investigate whether I could use angular routing to implement this instead.<\/p>\n<p>I have found a number of examples of varying degrees of complexity, which go at least some of the way. However, I have not seen what I would term a reasonably straightforward, out-of-the-box solution, which does not involve too much deep diving into the internals of angular.<\/p>\n<p>The following examples have been examined to date:<\/p>\n<p>A complex dynamic one here with perhaps useful ideas but actual components still appear to be declared in the angular app:<br \/><a href=\"https:\/\/medium.com\/ngconf\/dynamic-component-generation-in-lazy-loaded-routes-d2e0f9e89c57\">https:\/\/medium.com\/ngconf\/dynamic-component-generation-in-lazy-loaded-routes-d2e0f9e89c57<\/a><br \/>The code is here:<br \/><a href=\"https:\/\/github.com\/theAlgorithmist\/Angular8LazyLoadDynamic\">https:\/\/github.com\/theAlgorithmist\/Angular8LazyLoadDynamic<\/a><\/p>\n<p>Some specific ideas in this one here but still some way to go IMO&#8230;<br \/><a href=\"https:\/\/medium.com\/@timon.grassl\/how-to-use-routing-in-angular-web-components-c6a76449cdb\">https:\/\/medium.com\/@timon.grassl\/how-to-use-routing-in-angular-web-components-c6a76449cdb<\/a><\/p>\n<p>This one perhaps looks the most promising, and may have all the relevant techniques needed, but It still appears to have statically declared component objects which are used dynamically in a dynamic order&#8230;<br \/><a href=\"https:\/\/snyk.io\/advisor\/npm-package\/angular-elements-router\">https:\/\/snyk.io\/advisor\/npm-package\/angular-elements-router<\/a><\/p>\n<p>Some more research is needed on this as I am keen to fine the simplest solution which uses as little as possible of the deeper features of angular.<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Following on from my previous post on dynamic routing fundamentals, the ability to route dynamically across angular elements, i.e. to use the router to route to a dynamically loaded angular element, seems to be a sticking point. Previously, I developed a web components example where a &#8216;fabric&#8217; component was responsible for dynamically creating web components [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[198,236,77],"tags":[15],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2793"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2793"}],"version-history":[{"count":3,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2793\/revisions"}],"predecessor-version":[{"id":2796,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2793\/revisions\/2796"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}