aurelia-binding

2 way databinding in Aurelia custom elements - bind custom element to parent viewmodel

余生长醉 提交于 2019-12-01 16:37:57
In my application I have made a lot of "services" which I can inject in my viewmodels to save som redundancy and time. Now I'm looking to take it 1 step further, and make those form elements (select, text, checkboxes - a select dropdown for starters) and turn them into custom elements, injecting the service in only the custom element. I can get it working to some extent. The custom element (select in this case) is showing when I require it in the "parent" view, however when I change the selected value of the custom select element, it does not bind to the "parent" viewmodel, which is my

What is the correct way in aurelia to bind on a custom element using repeat.for

大憨熊 提交于 2019-12-01 16:03:46
Using Aurelia I am struggling with binding and repeat.for : suppose I have in my viewmodel with a property menuItems (an array of MenuItem ) I would like to repeat the menuitems with a custom template : export class App { menuItems : MenuItem[]; } export class MenuItem{ label:string; } In my app template I use use a custom element <require from="./menu-item"></require> <ul> <menu-item repeat.for="item of menuItems"></menu-item> </ul> My custom template (menu-item.html): <template> <li>${label}</li> </template> What is the correct way the get the template bound or access the bound MenuItem? I

2 way databinding in Aurelia custom elements - bind custom element to parent viewmodel

ⅰ亾dé卋堺 提交于 2019-12-01 14:37:58
问题 In my application I have made a lot of "services" which I can inject in my viewmodels to save som redundancy and time. Now I'm looking to take it 1 step further, and make those form elements (select, text, checkboxes - a select dropdown for starters) and turn them into custom elements, injecting the service in only the custom element. I can get it working to some extent. The custom element (select in this case) is showing when I require it in the "parent" view, however when I change the

How do get Aurelia to render my view after dynamically adding a custom element to the DOM?

末鹿安然 提交于 2019-12-01 14:31:03
问题 When creating a custom element in the DOM and adding a respective view model which implements bindable from the aurelia-framework, my view renders perfectly. custom element in DOM as so: <!-- chatbox.html --> <template> ... <ul class="chat"> <answer name="Reah Miyara" nickname="RM" text="Hello World"></answer> </ul> ... <button class="btn" click.trigger="addCustomElement()">Add</button> ... </template> Aurelia's magic rendering results in various children elements associated with the custom

Aurelia if.bind inside repeat.for is not updating

吃可爱长大的小学妹 提交于 2019-12-01 07:34:24
I have a strange case in an Aurelia template of elements with if.bind inside a repeat.for not being shown/hidden when their underlying property is changed. With the following code, the edit fields should be shown and the edit button should be hidden as soon as the edit button is clicked. Subsequently, both the save and undo buttons should hide the edit fields and show the edit buttons again. MyList.ts: import { computedFrom } from "aurelia-binding"; export class MyList { items: any[] = [{ "firstName": "Joe", "lastName" : "Blow", "id": 1 }, { "firstName": "Jane", "lastName" : "Doe", "id": 2 } ]

Aurelia if.bind inside repeat.for is not updating

雨燕双飞 提交于 2019-12-01 03:08:26
问题 I have a strange case in an Aurelia template of elements with if.bind inside a repeat.for not being shown/hidden when their underlying property is changed. With the following code, the edit fields should be shown and the edit button should be hidden as soon as the edit button is clicked. Subsequently, both the save and undo buttons should hide the edit fields and show the edit buttons again. MyList.ts: import { computedFrom } from "aurelia-binding"; export class MyList { items: any[] = [{

Array subscription in Aurelia

自作多情 提交于 2019-11-30 01:21:38
Let's say I have an array of elements and in addition to displaying the list in my app, I want to sync the list to the server with HttpClient . How can I observe changes to the array? I tried: @inject(ObserverLocator) export class ViewModel { constructor(obsLoc) { this.list = []; obsLoc.getObserver(this, 'list'); .subscribe(li => console.log(li)); } } But I got neither error nor log message. Jeremy Danyow getObserver returns a property observer which will notify you when the ViewModel class instance's list property changes. This will only happen when you assign a new value to the list property

Observe property on an array of objects for any changes

≡放荡痞女 提交于 2019-11-30 00:26:08
I am using Aurelia and I have an array of items bound to a grid and they have a selected property on them. I want to bind a button to be enabled when any one of the items is true. I can do a brute force approach where I have a getter that is filtering the list and returning the selected items, but that means that I would be doing dirty checking constantly in the app and I don't want to do that. I am hoping for a more efficient approach. Any ideas? Few things you could do- assuming I have your use case right: dirty-checking (it's only one property- not a big deal) export class Item { selected =

How to add bindable attributes or any other decorators to a typescript class via decorator?

ぃ、小莉子 提交于 2019-11-29 12:54:13
I want to extend the behavior and data of a class using decorators instead of inheritance. I also want to apply decorators as well to the newly created properties or methods. Is there an example of how to do this? Is this even possible? Imagine a set of classes where some of these classes share a bindable property named span . Also let there be a computed property named leftMargin dependent on the span property. The desired way to implement this would be to decorate the class with a decorator named @addSpan for example, that adds both the bindable property and the computed property to the

Aurelia: During a Router's Pipeline Step, how do I bind a variable to that router?

蓝咒 提交于 2019-11-29 07:20:28
I'd like to pass the user, found during the AuthorizeStep to either the App class and then to the home module . Here's what I have: export class App { configureRouter(config, router) { config.addPipelineStep('authorize', AuthorizeStep); config.map([ {route: ['', ':filter'], name: "", moduleId: 'welcome'} {route: 'home', name: "home", moduleId: 'home' auth:true} ]); this.router = router; } } class AuthorizeStep { run(routingContext, next) { if (routingContext.nextInstructions.some(i => i.config.auth)) { this.client.get('auth/login') .then(response => { this.user = response.content; }); } return