aurelia

ES6 and variable scope inside a promise

荒凉一梦 提交于 2019-12-01 20:42:14
Not sure what I'm missing here. I need to get the output of data into this.contact . Right now, I'm using a static class variable, but it seems dirty to have to do that. export class contactEdit { static t; // static class var constructor() { this.id = null; this.contact = null; contactEdit.t = this; } activate(id) { this.id = id; let contact = this.contact; // scoped version of class var return dpd.contacts.get(id).then(function(data) { console.log(data); contactEdit.t.contact = data; // this works contact = data; // this doesn't }); } } Normally I would create a var contact inside the

How to import Moment-Timezone with Aurelia/Typescript

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 20:16:29
问题 I've imported momentjs properly. It's working fine, but when I go to try to import moment-timezone, I can't get it to work. I don't have access to any functions. Here's my aurelia.json file where I'm loading them from npm: { "name": "moment", "path": "../node_modules/moment", "main": "moment", "exports": "moment" }, { "name": "moment-timezone", "path": "../node_modules/moment-timezone", "main": "moment-timezone", "deps": [ "moment" ], "exports": "tz" } and here's where I'm trying to load them

How to import Moment-Timezone with Aurelia/Typescript

只谈情不闲聊 提交于 2019-12-01 19:05:09
I've imported momentjs properly. It's working fine, but when I go to try to import moment-timezone, I can't get it to work. I don't have access to any functions. Here's my aurelia.json file where I'm loading them from npm: { "name": "moment", "path": "../node_modules/moment", "main": "moment", "exports": "moment" }, { "name": "moment-timezone", "path": "../node_modules/moment-timezone", "main": "moment-timezone", "deps": [ "moment" ], "exports": "tz" } and here's where I'm trying to load them into the file: import { autoinject } from "aurelia-framework"; import * as moment from "moment";

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

How to create a singleton service in Aurelia?

会有一股神秘感。 提交于 2019-12-01 15:56:35
I'm pretty new to Aurelia (only been using it a few days) and I love it! I know how to make a service with Aurelia, but how can I make that service a singleton that I can then share data with between multiple ViewModels? Thanks JamesCarters Just inject it By default, the DI container assumes that everything is a singleton instance; one instance for the app. However, you can use a registration decorator to change this. So I realized I was thinking about this too hard. I was trying to depend on the framework (Aurelia) to do all the work, but actually it was a simple ES6 class change that makes

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

How to pull in changes from skeleton sub-repository into production super-repository

别等时光非礼了梦想. 提交于 2019-12-01 12:55:17
I am using the Aurelia skeleton which contains various project setups for different purposes, but it is more of a general question of how you would do something with git like discribed below. I would like to be able to merge in the updates published in the GitHub skeleton repository to the project I am actually working on. How would you do that? At the moment I just initialized a new local repository in the skeleton-typescript project (which I am using) and connected it to a private remote repo to push my changes. But with this setup, I am polluting the parent repository (remote pointing to

How to pull in changes from skeleton sub-repository into production super-repository

拟墨画扇 提交于 2019-12-01 09:58:53
问题 I am using the Aurelia skeleton which contains various project setups for different purposes, but it is more of a general question of how you would do something with git like discribed below. I would like to be able to merge in the updates published in the GitHub skeleton repository to the project I am actually working on. How would you do that? At the moment I just initialized a new local repository in the skeleton-typescript project (which I am using) and connected it to a private remote