Additional viewport in Aurelia

I am setting up an application with several viewports. However, I want one of the viewports to be optional, i.e. If the viewport is not defined on a specific route, it simply should not be displayed. However, Aurelia gives an error if I try to do it. Is there any other way to make the viewport optional?

+4
source share
2 answers

If aurelia does not have built-in support, you can set up an unnecessary point of view on a module that has the following logic:

import {noView, inject} from 'aurelia-framework';

@noView
@inject(Element)
export class HiddenViewPort {
  constructor(element) {
    this.element = element;
  }

  activate() {
    // hide the router-view element
    this.element.parentNode.classList.add('aurelia-hide');
  }

  deactivate() {
    // show the router-view element
    this.element.parentNode.classList.remove('aurelia-hide');
  }
}
+2
source

, . - - :

import {inlineView} from 'aurelia-templating';

@inlineView('<template></template>')
export class EmptyViewModel {
}
0

Source: https://habr.com/ru/post/1612640/


All Articles