Skip to content

Instantly share code, notes, and snippets.

@Thanood
Created April 19, 2016 12:20
Show Gist options
  • Save Thanood/54748b3d8043726168a7b76d99a5865e to your computer and use it in GitHub Desktop.
Save Thanood/54748b3d8043726168a7b76d99a5865e to your computer and use it in GitHub Desktop.
Aurelia - optional viewport
<template>
<div>invisible<router-view name="toolbar"></router-view></div>
<div><router-view></router-view></div>
</template>
export class App {
configureRouter(config, router) {
config.title = 'Aurelia';
config.map([
{
route: ['', 'modal'],
name: 'modal', viewPorts: {
default: {
moduleId: './main-view'
},
toolbar: {
moduleId: './noViewPort'
}
},
nav: true,
title: 'Modal'
}
]);
this.router = router;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<link rel="stylesheet" href="styles.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/jspm_packages/system.js"></script>
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
<template>
<ul>
<li repeat.for="n of num">${n}</li>
</ul>
</template>
import {bindable} from 'aurelia-framework';
export class Paging {
@bindable() num = 5;
}
/*******************************************************************************
* The following two lines enable async/await without using babel's
* "runtime" transformer. Uncomment the lines if you intend to use async/await.
*
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2
*/
//import regeneratorRuntime from 'babel-runtime/regenerator';
//window.regeneratorRuntime = regeneratorRuntime;
/******************************************************************************/
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
aurelia.start().then(a => a.setRoot());
}
import { inlineView, inject } from 'aurelia-framework';
@inlineView('<template><span></span></template>')
@inject(Element)
export class NoViewPort {
constructor(element) {
this.element = element;
}
attached() {
this.element.parentNode.classList.add('aurelia-hide');
}
detached() {
this.element.parentNode.classList.remove('aurelia-hide');
}
}
/* Styles go here */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment