aurelia

How to pass (Debug vs Release) args to an Aurelia App within Asp.Net MVC

牧云@^-^@ 提交于 2019-12-22 08:49:32
问题 How would you go about passing Debug vs Release arguments to an Aurelia app? In my case, I have Aurelia within a MVC app. I would like to configure some parameters (URLs, etc.) for Aurelia depending on my web.config values. Is there a way I could to something like: <script src="~/Aurelia/jspm_packages/system.js"></script> <script src="~/Aurelia/config.js"></script> <script> System.import('aurelia-bootstrapper', @this.ViewBag.MyArgs); </script> Where this.ViewBag.MyArgs would contains

How to create a custom method for a given customRule in Aurelia Validation

荒凉一梦 提交于 2019-12-22 06:46:49
问题 I am using aurelia-validation, and I created a customRule. Rule validation logic: export function validateCompare(value: any, obj: any, otherPropertyName: string) { return value === null || value === undefined || value === "" || obj[otherPropertyName] === null || obj[otherPropertyName] === undefined || obj[otherPropertyName] === "" || value === obj[otherPropertyName]; } Configuration: import { ValidationRules, validationMessages } from "aurelia-validation"; import { validateCompare } from ".

How to create a custom method for a given customRule in Aurelia Validation

大憨熊 提交于 2019-12-22 06:46:15
问题 I am using aurelia-validation, and I created a customRule. Rule validation logic: export function validateCompare(value: any, obj: any, otherPropertyName: string) { return value === null || value === undefined || value === "" || obj[otherPropertyName] === null || obj[otherPropertyName] === undefined || obj[otherPropertyName] === "" || value === obj[otherPropertyName]; } Configuration: import { ValidationRules, validationMessages } from "aurelia-validation"; import { validateCompare } from ".

Handle a 500 response with the fetch api

前提是你 提交于 2019-12-22 04:16:25
问题 We have the following call to fetch . this.http.fetch('flasher', { method: 'post', body: jsonPayload }) .then(response => response.json()) .then(data => console.log(data)); This works when we receive a 200 response but logs nothing to the console when we receive a 500 response. How do we handle a 500? 回答1: Working Solution Combining then with catch works. fetch('http://some-site.com/api/some.json') .then(function(response) { // first then() if(response.ok) { return response.text(); } throw

When does binding to ref attribute become valid in Aurelia?

时光总嘲笑我的痴心妄想 提交于 2019-12-22 03:52:18
问题 This is a follow up to this question: Access a DOM element in Aurelia Is there a hook in the Screen Activation Lifecycle which allows me to run code after ref bindings have been set up? Currently it seems like there is a period of time after the activate hook is called when the ref bindings are not set up yet and then at some point they get activated. I tested this by adding a <div ref="myDiv"></div> to near the bottom of welcome.html in a cloned version of the latest (v0.13.0) skeleton

Can Onsen be used without Angular? I would rather use Aurelia

你说的曾经没有我的故事 提交于 2019-12-21 22:32:37
问题 Can Onsen be used without Angular? Can Aurelia data bind to Onsen? 回答1: Yes, it can be used without Angular. You would need to take advantage of their css, and develop your custom components like the way they did for Angular. For example, a simple ons-list Custom Element would be something like: ons-list ons-list.html <template> <ul class="list ${inset ? 'list--inset' : ''}"> <content select="ons-list-header"></content> <content select="ons-list-item"></content> </ul> </template> ons-list.js

Aurelia starting with params passed by PHP

 ̄綄美尐妖づ 提交于 2019-12-21 21:24:40
问题 I need to pas params to Aurelia on start. Depending on values passed the application will have diffrent state. This application is injected on page which is build with PHP, so the best way would be starting it with parameters specified with PHP code. Is there any way to do this? 回答1: Any data you can access in normal JS you can access with Aurelia. Maybe you could use a data-* attribute to do this? When you use a main file by doing aurelia-app="main", the framework instance you get passed to

Two-Way binding in an Aurelia Custom Attribute

邮差的信 提交于 2019-12-21 10:13:28
问题 UPDATE: It looks like this is a known bug: https://github.com/aurelia/templating/issues/253 I am leaving it here for reference / searchability purposes. The Code: input-mask.ts (Full code can be seen here) @customAttribute('input-mask') @inject(Element) export class InputMaskCustomAttribute { @bindable({ defaultBindingMode: bindingMode.twoWay, changeHandler: 'onUnmaskedValueChanged' }) unmaskedValue: any; onUnmaskedValueChanged(newValue, oldValue) { console.log('unmaskedValue updated from

Two-Way binding in an Aurelia Custom Attribute

…衆ロ難τιáo~ 提交于 2019-12-21 10:13:11
问题 UPDATE: It looks like this is a known bug: https://github.com/aurelia/templating/issues/253 I am leaving it here for reference / searchability purposes. The Code: input-mask.ts (Full code can be seen here) @customAttribute('input-mask') @inject(Element) export class InputMaskCustomAttribute { @bindable({ defaultBindingMode: bindingMode.twoWay, changeHandler: 'onUnmaskedValueChanged' }) unmaskedValue: any; onUnmaskedValueChanged(newValue, oldValue) { console.log('unmaskedValue updated from

Data binding parent-child relationships in Aurelia

筅森魡賤 提交于 2019-12-21 05:06:35
问题 The Code: I have two classes: export class Shipment { shipmentId: number; widget: Widget; } export class Widget { widgetId: number; name: string; } Then I have a ShipmentUi view-model that has an instance of shipment ( this.shipment ). And in the ShipmentUi view I compose part of the UI show the WidgetUi that allows selection of the Widget: <compose view-model="src/views/widgetUi" model.bind="shipment"></compose> The WigetUi's view-model saves off the shipment. So WidgetUi has a this.shipment