I looking into aurelia@2.0.0-beta.2 project that is using @aurelia/router-lite. Based on getting started examples, I’ve noticed that components now require:
import { customElement } from '@aurelia/runtime-html';
import template from './home.html';
@customElement({ name: 'ho-me', template })
export class Home {
private readonly message: string = 'Welcome to Aurelia2 router-lite!';
}
HTML template has to be imported and explicitly assigned to the @customElement decorator.
Is there a way to customize ViewStrategy as it was the case in Aurelia 1?
For certain custom elements, I would use custom @useRemoteView decorator, which relies on custom ViewStrategy (RemoteViewStrategy), to fetch template HTML from server:
@useRemoteView("/template/home")
export class Home {
}
Hi @nenadvicentic! The process of creating a custom element definition is completely synchronous ATM. However, you can create your own infra to fetch the template from a remote source, and then use the CustomElement.define API to create the custom element definition, and thereafter register to the DI, if neeeded.
Uncaught Error: Invalid route config property: “.routes[0].component”. Expected function, object or string (see Routeable), but got undefined.
On top of that, even if this would work, this code is extremely unmaintainable, since it’s completely differs from regular code of Aurelia. And I did not even try to add component properties and functions yet.
Is there any plan to implement something similar to ViewStrategy from Aurelia v1, that is easily customizable by end-user?