aurelia

A default parent router with child routers

元气小坏坏 提交于 2019-12-24 08:20:03
问题 Consider the following two classes: import { Router, RouterConfiguration } from 'aurelia-router'; export class MainPage { router: Router; configureRouter(config: RouterConfiguration, router: Router) { config.map([ { route: ['', 'entities'], name: 'entities', moduleId: './entities/entities', nav: true, title: 'Entities' }, { route: 'structures', name: 'structures', moduleId: './structures/structures', nav: true, title: 'Data Structures' }, ]); this.router = router; } } And import { Router,

Aurelia validating nested objects

折月煮酒 提交于 2019-12-24 07:41:17
问题 I'm trying to validate an object property of an Aurelia ViewModel. ViewModel @autoinject class AddUserForm { user: User; controller: ValidationController; constructor(controllerFactory: ValidationControllerFactory) { this.controller = controllerFactory.createForCurrentScope(); } validate() { this.controller.validate.then(res => { console.log(res.valid); }) } } ValidationRules .ensure((u: User) => u.id).displayName('User').required() .on(AddUserForm) ViewModel -> View <template> <form click

Pass array from parent template to child template

落花浮王杯 提交于 2019-12-24 01:19:56
问题 Situation We have been able to pass an array from the parent screen to the template. The customAttribute works but the historyItems does not. parent-template.html <template> <require from="./child-template"></require> <child-template historyItems.bind="history[0].HistoryItems" custom-attribute.bind="history[0].HistoryItems.length"> </child-template> </template> child-template.html <template> ${customAttribute} ${historyItems.length} ${historyItems} <p repeat.for="item of historyItems"> Foobar

Aurelia, how to make optional binding

跟風遠走 提交于 2019-12-24 00:56:47
问题 Does Aurelia support optional binding? I can't find this information anywhere. The issue that I'm having is that I have a title attribute that might or might not be populated in an array of objects. I use a repeat.for and title.bind but I don't want the attribute to exist at all if this property is not part of the array of objects. Is that possible in Aurelia ? When using Bootstrap-Select with an empty title it throws an error. Having Aurelia to create attribute on the fly would resolve my

Aurelia bundling fails when using relative import path

北城余情 提交于 2019-12-23 20:51:42
问题 I'm using aurelia with typescript and I wanted to avoid using relative import path like : import { DialogBox } from '../../resources/elements/dialog-box'; but rather import { DialogBox } from 'resources/elements/dialog-box'; I modified my tsconfig.json so the compiler handles relative paths by adding baseUrl and paths like this: "compilerOptions": { "sourceMap": true, "target": "es5", "module": "amd", "declaration": false, "noImplicitAny": false, "removeComments": true, "emitDecoratorMetadata

Router authorizeStep from other app root keeps triggering

混江龙づ霸主 提交于 2019-12-23 20:23:06
问题 My Aurelia project is split up in 2 app roots, both with their own route structure. App root 1 contains all screens where you don't have to be authenticated (login, reset pwd,...) App root 2 all the other screens. I'm blocking access to routes on app root 2 when you are not authenticated with an authorizeStep. In this step, I set the root to app root 1 when you are not authenticated. App root 1 has a login view as default route, so this works quite well. So, when you are not authenticated and

Technique for jquery change events and aurelia

梦想与她 提交于 2019-12-23 15:44:26
问题 I need to find a reliable solution to making the two frameworks play nicely. Using materialize-css, their select element uses jquery to apply the value change. However that then does not trigger aurelia in seeing the change. Using the technique of... $("select") .change((eventObject: JQueryEventObject) => { fireEvent(eventObject.target, "change"); }); I can fire an event aurelia sees, however, aurelia then cause the event to be triggered again while it's updating it's bindings and I end up in

If Aurelia understands “import”, why use dependency injection?

ⅰ亾dé卋堺 提交于 2019-12-23 15:16:52
问题 I don't understand.. if I can use import in Aurelia, why do I have to wire up the constructor with @autoinject() and all that? I'm sure I'm missing something, but, from what I can tell, I can just use my imported module whenever I want. import something from "whatever" export class SomeViewModel { activate() { // use something } } 回答1: Typically, in an Aurelia application, the thing you are import ing isn't an instance of Something it's the class Something . To actually use whatever has been

Most efficient Aurelia binding way for a singleton object

拟墨画扇 提交于 2019-12-23 12:13:38
问题 Here's a pretty fundamental JavaScript and Aurelia question. Let's say that I have a singleton object, for example User and it would often get updates from the server, which returns a whole new User object. Now, to push the update to the views, I have two options (that I know of): Update every property of the existing User to that of the new User 's manually (this would also require mapping every property). Replace the object reference and push an EventAggregator notification for all

Nested Aurelia applications

杀马特。学长 韩版系。学妹 提交于 2019-12-23 10:22:09
问题 According to Rob Eisenberg, the creator of Aurelia, it should be possible to have nested aurelia applications inside each other. Since the example he mentions in the above link is not public anymore, it'd be very helpful if anyone here could elaborate further, or even link or write a small example of how this sort of nesting would be implemented. The main application and interface I'm hoping to create with Aurelia would consist of a Windows XP Desktop style-ish shell, in which one would be