aurelia

Aurelia Custom Attribute with setAttribute method()

六眼飞鱼酱① 提交于 2019-12-20 02:59:11
问题 It seems Aurelia is not aware when I create and append an element in javascript and set a custom attribute (unless I am doing something wrong). For example, const e = document.createElement('div'); e.setAttribute('custom-attr', 'some value'); body.appendChild(e); Is there a way to make Aurelia aware of this custom attribute when it gets appended? A little background: I am creating an app where the user can select their element type (e.g. input, select, checkbox etc.) and drag it around (the

Capture div containing inline svg and download it as image

ぃ、小莉子 提交于 2019-12-20 02:34:43
问题 I wrote code to capture a screenshot of a page using html5. Everything is fine except when the page contains an svg. When I convert svg to inline svg after that screenshot is not capturing the inline svg. Please check https://jsfiddle.net/7bqukhff/4/ <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.3/FileSaver.min.js"></script> <script src="https://github.com/niklasvh/html2canvas/releases/download/0.5.0-alpha1/html2canvas.svg.js"></script> <script src="https://github.com

Remote Service in Aurelia Component Lifecycle

陌路散爱 提交于 2019-12-20 02:28:35
问题 I'm trying to figure out at what point of the component lifecycle do I call into a remote service? I'm looking to create components that are tied to a remote service so instead of having my remote service be called using the activate callback as part of the screen activation lifecycle, each component would call the remote service themselves. They would show a loading animation until they have received the data from the remote service. 回答1: Use the attached callback. When a viewmodel has an

ES6 and variable scope inside a promise

可紊 提交于 2019-12-20 01:33:52
问题 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; //

Unexpected token m in JSON at position 0 error

馋奶兔 提交于 2019-12-19 17:04:24
问题 On compiling an app and trying to implement the i18n library with webpack, I face this error: ERROR in ./node_modules/bundle-loader?lazy&name=lang-pt!./src/locales/pt/translation.json Module parse failed: Unexpected token m in JSON at position 0 You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token m in JSON at position 0 at JSON.parse (<anonymous>) at JsonParser.parse (C:\Users\vasco.bento\ContactosWebPack\node_modules\webpack\lib\JsonParser.js:15:21) at

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

喜你入骨 提交于 2019-12-19 15:42:40
问题 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

How to create a singleton service in Aurelia?

 ̄綄美尐妖づ 提交于 2019-12-19 12:45:13
问题 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 回答1: 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. 回答2: So I realized I was thinking about this too hard. I was trying to depend on

How to remove # from URL in Aurelia

☆樱花仙子☆ 提交于 2019-12-18 03:17:28
问题 Can anybody please explain in step by step manner, how can we remove # from URL in Aurelia 回答1: The feature you are looking for is called PushState. You can find more info in Cheat Sheet section of Aurelia Hub. Just scroll down to Routing / Configuring PushState . Add a base tag to the head of your HTML document. I don't think this is a required step, since my apps are working without it. If you are using JSPM, configure baseURL (in config.js file). Enable PushState in router config: export

How do you substitute HttpClient in Aurelia?

懵懂的女人 提交于 2019-12-17 15:57:29
问题 I'm brand new to Aurelia. How would you change the following code to provide a dummy HttpClient, e.g. a json reader instead that would provide just a static set of json data, negating the need for a server in development. import {inject} from 'aurelia-framework'; import {HttpClient} from 'aurelia-fetch-client'; @inject(HttpClient) export class Users { heading = 'Github Users'; users = []; constructor(http) { http.configure(config => { config .useStandardConfiguration() .withBaseUrl('https:/

Aurelia - A way to add a divider into a multi level drop down menu

我只是一个虾纸丫 提交于 2019-12-14 02:25:18
问题 I have a multi level dropdown menu working for Aurelia with bootstrap however whilst its three levels deep and uses as a basis THIS gist expanding on it I am having trouble adding a divider via the route settings. Now a divider uses the class "divider" in the list tag <li></li> Ok so I thought by adding the entry divider: true in the settings for the dropdown I could check for that and instead if displaying the link etc I could instead show a divider however I dont know how to implement this