Inherit Parent Route Parameters by Default with ParamsInheritanceStrategy

InstructorSam Julien

Share this video with your friends

Send Tweet

Right now, we're getting the ID route parameter off the of the parent route. This is because we want the info and items components to use the ID of the chosen camping system without having to pass it a second time. There's another way we can do this, though, and that's by defining a paramsInheritanceStrategy when we create our router module. The paramsInheritanceStrategy defines how the router merges parameters, data, and resolved data from parent to child routes. The default is "emptyOnly," which inherits those only for path-less or component-less routes. We're going to set it to "always" to enable unconditional inheritance of parent parameters, data, and resolved data in child routes.