Skip to content

Instantly share code, notes, and snippets.

@brakmic
Last active March 12, 2017 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brakmic/a20aa639802e5d5625314576b10da318 to your computer and use it in GitHub Desktop.
Save brakmic/a20aa639802e5d5625314576b10da318 to your computer and use it in GitHub Desktop.
reacting to route changes in vrwrappercomponent
// Each time the route changes take the ID and instantiate the appropriate vr element.
// If the element contains a script-array load them too.
// Check shared/directives/vr-element.directive.ts for more info regarding
// dynamic instantiation of vr elements.
this.routeSubscription = this.route.params.subscribe((params) => {
const id = params['id'];
const mod = _.find(this.availableModules, (m) => m.id === id);
if (!_.isNil(mod)) {
this.dynamicComponent = {
html: mod ? mod.markup : undefined,
scripts: mod ? mod.scripts : []
};
this.changeDetectorRef.markForCheck();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment