aurelia

Centralize Aurelia validation logic

女生的网名这么多〃 提交于 2019-12-25 04:09:02
问题 I would like to centralize validation logic in @ensure but I am not sure how to do it. This is an example from documentation: import {Validation} from 'aurelia-validation'; import {ensure} from 'aurelia-validation'; export class Person { static inject() { return [Validation];} //I want to inject validation logic here instead of using function(it){...} @ensure(function(it){ it.isNotEmpty().hasLengthBetween(3,10) }) firstName = 'John'; constructor(validation) { this.validation = validation.on

Dockerized Aurelia App Is Not Visible Outside of Docker Container - Not listening on 0.0.0.0

自古美人都是妖i 提交于 2019-12-25 01:17:43
问题 I'm running an Aurelia app inside of the standard node docker container and it is listening on port 8080. Within the container, I have tested that it's running using curl ; and it responds with the expected HTML. But I cannot reach the app via the mapped port on the host (outside the container). I'm running the following command to start the container $ docker run -it --rm -p 8080:8080 -v ${PWD}:/app node bash Then inside the container, I install the cli and create a new app # npm install -g

How to disable a custom component with authorize custom attribute in Aurelia

被刻印的时光 ゝ 提交于 2019-12-24 22:45:06
问题 I'm trying to create some authorization logic for my custom components. What I want to achieve is that I can set an attribute which disables the component entirely, e.g. when a user has read-only rights. I tried with a button but am not really satisfied with it. I'm basing my work upon the solution to this question my-button.html: (currently html only) <template bindable="icon, disabled"> <require from="./buttons.css"></require> <button class="btn btn-danger" disabled.bind="disabled"> <slot

Is constant polling the way Aurelia's change detection is working?

江枫思渺然 提交于 2019-12-24 12:18:14
问题 I got div with if.bind working as was suggested in this question: Using literal JavaScript values in an Aurelia view. But then I noticed that showTemplate on viewModel is being constantly checked by framework, about 10 times per second. The stack is following: execute._prototypeProperties.visible.get (welcome.js:29) getValue (dirty-checking.js:93) isDirty (dirty-checking.js:127) check (dirty-checking.js:63) (anonymous function) (dirty-checking.js:49) Is it supposed to be like this? Seems to

Multiple Aurelia Instances - Aurelia Webpack Plugin - aureliaApp option - “module not found”

风格不统一 提交于 2019-12-24 10:56:35
问题 I am composing my web app as a number of Aurelia "feature" apps - although I'm not using Aurelia features as such. Consequently in my html markup I have two entry points pointing to different apps: <!-- Top Navigation Bar --> <div aurelia-app="topnav"></div> <!-- Main App--> <div aurelia-app="main"></div> I am using webpack and everything works perfectly using the single "main" app. Webpack generates a JS file "main.bundle.js" which I include in the src tag. Things are not so straightforward

Dependency Injection Constructor that takes arguments

有些话、适合烂在心里 提交于 2019-12-24 10:32:13
问题 I'm building an Aurelia app that uses "Models" for every type of data object. All my Models look something like this: export class Item { id = null; name = ''; description = ''; constructor (data) { Object.assign(this, data); } } And I later create objects like this: export class SomeViewModel { activate () { this.myItem = new Item({ name: 'My Item!', description: 'This is my item. It will be initialized with these properties.' }); } } I got the Object.assign() bit from an article I read and

Aurelia prints __observers__ instead of object

拈花ヽ惹草 提交于 2019-12-24 10:31:09
问题 I am trying to bind an object from the view-model to view as follows: // welcome.js export class Welcome { constructor() { this.data = { a: "", b: "", c: "" } } submit() { console.log(this.data); } } // welcome.html <form role="form" submit.delegate="submit()"> <div class="form-group"> <textarea class="form-control" value.bind="data.a" rows="3"></textarea> </div> <button type="submit" class="btn btn-default">Submit</button> </form> Ideally, it should print only data object. However, it prints

Intermittent unit-test failure associated with i18next

▼魔方 西西 提交于 2019-12-24 09:06:01
问题 I am trying to unit test my aurelia custom element, which looks like below. // BaseText.ts import { bindable } from "aurelia-framework"; import { BaseI18N } from "aurelia-i18n"; export class BaseText extends BaseI18N { @bindable public value: string; @bindable public i18nKey: string; } // NormalText.ts export class NormalTextCustomElement extends BaseText {} // NormalText.html <template> <span t.bind="i18nKey">${value}</span> </template> Now, I want to test if I change the value of i18nKey ,

Dynamically add to Dom with Aurelia

一笑奈何 提交于 2019-12-24 08:47:00
问题 I've been looking at the aurelia-dialog project(focused mostly on the renderer piece) as I was hoping to do something similar. I like the toastr project, but can't seem to get it to work with Aurelia CLI(though I can get it to work with the Typescript skeleton project). I started to work on an independent solution(I would like it to work independent from jQuery), but can't seem to understand why this isn't working. I created a new project using the au new command. I updated the app.ts file to

Aurelia popover checkbox checked.bind not reflecting on the view model

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 08:23:57
问题 We have implemented checkbox in popover. There we are using checked.bind , but in the view model its not reflecting its value on change of the checkboxes. Sample Gist Run Provided below: Gist Run Thanks in Advance 回答1: Programmatically injected HTML needs to be compiled manually The integration with bootstrap I provided to you earlier cannot do this. The bootstrap plugin assigns the innerHTML property of the popover and it does this outside of aurelia's rendering pipeline. The HTML is