aurelia

Array subscription in Aurelia

那年仲夏 提交于 2019-11-28 21:31:45
问题 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. 回答1: getObserver returns a property observer which will notify you when the ViewModel class instance's

Observe property on an array of objects for any changes

試著忘記壹切 提交于 2019-11-28 21:21:55
问题 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? 回答1: Few things you could do- assuming I have

Assisted injection in Aurelia?

二次信任 提交于 2019-11-28 20:36:04
问题 I have a class whose constructor has two arguments; one is a dependency, the other is a configuration property: @inject(Dependency) class MyClass{ constructor(dependency, config){ } } How can I make use of Aurelia's dependency injection to automatically inject the dependency but allow the class's consumer to specify the config value? 回答1: Here are some options: Option 0: Factory Resolver foo.js import {inject} from 'aurelia-framework'; import {FooDependency} from './foo-dependency'; @inject

@bindable changeHandler fires before bindings are done updating

╄→尐↘猪︶ㄣ 提交于 2019-11-28 14:00:24
The Code: App.js export class App { constructor() { this.widgets = [{ name: 'zero'}, {name: 'one'}, {name:'two'}]; this.shipment = { widget: this.widgets[1] }; } } App.html <template> <require from="./widget-picker"></require> <require from="./some-other-component"></require> <widget-picker widget.bind="shipment.widget" widgets.bind="widgets"></widget-picker> <some-other-component widget.bind="shipment.widget"/> </template> widget-picker.js import {bindable, bindingMode} from 'aurelia-framework'; export class WidgetPicker { @bindable({ defaultBindingMode: bindingMode.twoWay, changeHandler:

How can I configure two or more apps in Aurelia using Webpack

我们两清 提交于 2019-11-28 08:50:31
问题 I'm trying to wrap my head around the starter kit skeleton-esnext-webpack and the way the Aurelia team has set up the webpack.config.babel.js Now that I have somehow understood how to configure a basic project in Aurelia, before I go any further, what I want to know is whether it is possible to configure more than one app ( aurelia-app ) using Webpack and how? The "Quick Start" guide gave the impression that it is possible by creating more than one js file, each of which should export a

Aurelia trying to load HTML from Select2?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 08:15:34
问题 So I'm trying to use Select2 within my Aurelia application. I installed Select2 using jspm install select2 , and within my app.html file I require Select2 using <require from="select2/js/select2.min.js"></require> . The browser loads the minified JS file fine, but for some reason it also tries to load http://localhost:3003/jspm_packages/github/select2/select2@4.0.0/js/select2.min .html . Why is Aurelia trying to load the HTML counterpart of the same JS file that I specified in my <require>

ES6 / ES7 support in Visual Studio 2015 Community

本秂侑毒 提交于 2019-11-28 08:09:25
I'm hearing that VS 2015 is supporting the new js syntax but when I open up a project written using aurelia.js in this IDE intellisense complains about many, many things eg. export class UpperValueConverter { toView(value){ return value && value.toUpperCase(); } } I have the WebEssentials 2015 installed. Still nothing seems to work... Probably an important information is that my current VS installation is a fresh one, so I didn't mess up any settings. I was having this problem in .jsx files, visual studio 2015 was using the react-tools plugin to parse and highlight the syntax errors. I can't

Configure IIS server to work with Aurelia framework and push state

强颜欢笑 提交于 2019-11-28 07:13:40
问题 I have created a basic aurelia app starting from this repo and I was trying to get rid of the # (hashtag) in the URL bar. I have 2 projects, one running WebApi on a machine and one running an empty web project (not MVC) on another machine. On the official documentation website it only says how to configure your routes but my project is not MVC oriented. How can I configure the IIS server from Web.config in a sense that when I access http://localhost/home it should start the aurelia framework

Using materialize in aurelia

家住魔仙堡 提交于 2019-11-28 06:43:33
问题 I have been trying to get the materialize-css framework to work with Aurelia. I am using Typescript with the framework, and running the server on Windows 8 through the cmd with 'gulp watch'. So far I have attempted to use the aurelia-materialize bridge, following the instructions provided. However, after I have followed the steps, I get the following console output using chrome: console error The cmd is clean of errors. These are the contents of the main.ts and index files which are the

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

我只是一个虾纸丫 提交于 2019-11-28 06:37:36
问题 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