Skip to content

Instantly share code, notes, and snippets.

@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>
@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 / 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 / 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 / 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;
}
}
/** 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.
/** 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
@atsu85
atsu85 / app.html
Created July 4, 2016 11:27 — forked from anonymous/app.html
Aurelia view engine hooks
<template>
<p>How to get selected checkbox values to array?</p>
<p>Follwoging <a href="http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/cheat-sheet/5" target="_blank">sample</a> isn't workign:</p>
<label repeat.for="color of colors">
<input type="checkbox" value.bind="color" checked.bind="$parent.favoriteColors" />
${color}
</label>
<p>PROBLEM: expecting array of selected values, not boolean: favoriteColors=${favoriteColors}</p>
</template>
<template>
<div repeat.for="person of persons">
<span with.bind="person" element.ref="el">
${firstName} ${middleName} ${lastName}
</span>
</div>
app.el = ${el} <-- this (global el) should be null
<br/>
person[0].el = ${persons[0].el}
<br/>
@atsu85
atsu85 / app.html
Last active May 19, 2016 16:06
Aurelia Gist
<template>
<h1>this video is being played twice if the autoplay attribute isn't bound to VM property. Pause and see</h1>
<video src="http://video.webmfiles.org/big-buck-bunny_trailer.webm"
ref="player" loop controls autoplay="${autoplay}"></video >
</template>