Skip to content

Instantly share code, notes, and snippets.

/** This file contains interfaces for Screen Activation Lifecycle hooks that Views can use. */
declare module 'aurelia/lifecycle/view-hooks' {
import {Router, RouterConfiguration, RouteConfig, NavigationInstruction} from "aurelia-router";
/**
* A Navigation Command is any object with a navigate(router: Router) method.
* When a navigation command is encountered, the current navigation will be cancelled and
* control will be passed to the navigation command so it can determine the correct action.
*/
export type NavigationCommand = {
navigate(appRouter: Router): void
/** This file contains interfaces for lifecycle hooks that all HTML Behaviors (such as Views and Custom Elements) can use. */
declare module 'aurelia/lifecycle/html-behavior-hooks' {
import {View} from "aurelia-framework";
/** the first Html Behavior hook, that is called after the constructor */
export interface Created {
/**
* If the view-model implements the created callback it is invoked next.
* If your behavior is a custom element, it's view has also been created and both the view-model and the view are connected to their controller.
* The created callback will receive the instance of the "owningView".
* This is the view that the component is declared inside of.
@atsu85
atsu85 / Validator.js
Last active September 7, 2016 09:38 — forked from sylvain-hamel/app.html
binding two values (test)
export class Validator{
constructor(){
this.violatedConstraints = 10;
}
}
@atsu85
atsu85 / aurelia-template-lint.js
Last active September 15, 2016 15:02
gulp task `lint-templates` to lint Aurelia templates (also shows UI notification when there is a problem or when all problems are fixed)
var gulp = require('gulp');
var linter = require('gulp-aurelia-template-lint');
var config = new (require('aurelia-template-lint').Config);
var fail = require('gulp-fail');
var gulpIf = require('gulp-if');
var gutil = require('gulp-util');
var notify = require("gulp-notify");
var paths = require('../paths');
@atsu85
atsu85 / enhance-bug.html
Last active October 9, 2016 10:23
Aurelia Enhance Bug
<template>
<require from="./relation-field.html"></require>
<h1>${message}</h1>
<!-- Fails on consecutive enhance -->
<compose repeat.for="relation of data.relations" view="./relation-field.html" view-model.bind="relation"></compose>
<!--Will fail as well-->
<!--<relation-field repeat.for="relation of data.relations" relation.bind="relation"></relation-field>-->
@atsu85
atsu85 / app.html
Last active May 10, 2017 00:44 — forked from jdanyow/app.html
Aurelia OnKeyBindingBehavior (`keyup.delegate="eventHandler(message) & onKey:'enter'"`)
<template>
<require from="./on-key"></require>
Press enter in textbox to trigger event:
<input
value.bind="message"
keyup.delegate="textEntered() & onKey:'enter'"
/>
${message}
</template>
@atsu85
atsu85 / app.html
Last active May 8, 2017 22:04
Handle enter keypress on text input with form submit handler
<template>
Press enter in textbox to trigger event:
<form submit.delegate="textEntered()">
<input value.bind="message" />
</form>
${message}
</template>