aurelia

Aurelia Unsubscribe Event Aggregator

独自空忆成欢 提交于 2019-12-06 17:16:36
问题 I am using Aurelia Framework with Typescript and in the event aggregator I am able to publish and subscribe to channels. The problem is that I am unable to unsubscribe from a channel. Note: All forms of the subscribe method return a dispose function. You can call this function to dispose of the subscription and discontinue receiving messages. A good place to dispose is either in a view-model's deactivate callback if it is managed by a router, or in its detached callback if it is any other

Getting the current route in Aurelia

一曲冷凌霜 提交于 2019-12-06 17:15:26
问题 To get the current route within a non-view-model class, would the best practice be to inject the Router and use this.router.history.fragment? Or is this a no-no? 回答1: You could inject the router and get the current instruction. Like this: import { inject } from 'aurelia-dependency-injection'; //or framework import { Router } from 'aurelia-router'; @inject(Router) export class MyClass { constructor(router) { this.router = router; } getRoute() { return this.router.currentInstruction.config.name

Importing ElasticSearch into Aurelia

有些话、适合烂在心里 提交于 2019-12-06 16:07:27
I'm trying to use elasticsearch-js within my Aurelia app but running into some trouble. After executing npm install elasticsearch , elasticsearch is installed under: app/node_modules/elasticsearch . In my app.js , I try to pull it in with import {elasticsearch} from 'elasticsearch'; and in the javascript console, I get the following error: system.src.js:4840 GET http://localhost:9000/dist/elasticsearch.js 404 (Not Found)D @ system.src.js:4840(anonymous function) @ system.src.js:4840Promise @ shim.min.js:1847(anonymous function) @ system.src.js:4840(anonymous function) @ system.src.js:4840

Aurelia How do I use a Child Router and dynamics child routes

て烟熏妆下的殇ゞ 提交于 2019-12-06 15:38:17
Trying to use a child route in Aurelia. Can't seem to get my head around the workings of nested routes. Are all routes derived from the root of the app or relative to location of the current router? Why wont my route-href work in this example? I have a route in this router named screen and it does have an :id parameter screens/list.ts @inject(Router) export class ScreensList { heading; router; screens: any[]; constructor(router){ this.heading = 'Child Router'; this.router = router; this.screens = [ { id: 1, name: 'my screen' }, { id: 2, name: 'my other screen' } ] router.configure(config => {

Access an element's Binding

寵の児 提交于 2019-12-06 14:23:37
问题 I have a custom attribute that processes authentication data and does some fun stuff based on the instructions. <div auth="disabled: abc; show: xyz; highlight: 123"> There's a lot of complicated, delicate stuff happening in here and it makes sense to keep it separate from semantic bindings like disabled.bind . However, some elements will have application-logic level bindings as well. <div auth="disabled.bind: canEdit" disabled.bind="!editing"> Under the covers, my auth attribute looks at the

Unit testing logic inside promise callback

£可爱£侵袭症+ 提交于 2019-12-06 13:09:13
I have an ES6 / Aurelia app that I am using jasmine to test. The method I am trying to test looks something like this: update() { let vm = this; vm.getData() .then((response) => { vm.processData(response); }); } Where this.getData is a function that returns a promise. My spec file looks something like this: describe('my service update function', () => { it('it will call the other functions', () => { myService = new MyService(); spyOn(myService, 'getData').and.callFake(function() { return new Promise((resolve) => { resolve(); }); }); spyOn(myService, 'processData').and.callFake(function() {

How to use Aurelia third party plugin with without typescript definition file?

。_饼干妹妹 提交于 2019-12-06 11:12:47
I am new to Aurelia and Typescript. I am trying to use a the aurelia-dialog plugin inside of my project. I have follow all the necessary steps and am getting an error "cannot find module "aurelia-dialog". The offending line is import {DialogService, DialogController} from "aurelia-dialog"; I am pretty sure all of the config is set up correctly because this is my only error. I have aurelia.use .standardConfiguration() .developmentLogging() .plugin('aurelia-dialog'); Do I need to create a typescript definition file for this to work, if so how? Or am I missing something and this should work as-is

How to import packages within my Aurelia application

ぃ、小莉子 提交于 2019-12-06 10:09:05
I have a successful app running using Aurelia, however I developed it using VSCode and the skeleton that Aurelia gives you. Now that the CLI is available I'm trying to port the application over to a VS2015/Asp.net Core project but I'm having some difficulties. In the VSCode project, there's a bundles.js file within the build folder that Gulp uses to compile it (from what I understand). In that file, there's a "dist/aurelia" section and that's where I put all of the extra packages that I need to import and it will import the css and js files. Looks like this: "dist/aurelia": { "includes": [

Return Promise from activate() when customElements have loaded

巧了我就是萌 提交于 2019-12-06 08:53:04
问题 I know that Aurelia allows us to return a Promise() from the VM's activate() method, and if so it'll wait for the promise to resolve before switching to the new view. But, say I have a view that consists of one or several child components and they all make HTTP requests, how can I know when all children are finished from within my parent component? Bonus question: Is it correct that only VM's that go in the <router-outlet> utilize the activate() method, whereas VM's that are used as custom

Difference between a Component and a View in Aurelia (and their lifecycles)

拈花ヽ惹草 提交于 2019-12-06 07:02:00
问题 Could you please tell me what is difference between a component and a View in Aurelia? What are their architectures and What is the difference between their lifecycles? 回答1: As a rule of thumb, the difference between a view and a component in Aurelia can be summarised as: A view in Aurelia is simply put the .html and the styling that comes with it (.scss/.less/.css) A view-model in Aurelia is the code behind it (.js/.ts class) A component is the combination between a view and view-model, and