Skip to content

Instantly share code, notes, and snippets.

@MT-PL-SWF-Dev
Forked from jdanyow/app.html
Last active October 14, 2016 09:37
Show Gist options
  • Save MT-PL-SWF-Dev/2e0ff35d2e08641448e536d639e31a12 to your computer and use it in GitHub Desktop.
Save MT-PL-SWF-Dev/2e0ff35d2e08641448e536d639e31a12 to your computer and use it in GitHub Desktop.
Aurelia Gist
<template>
<h1>Main Page</h1>
<router-view></router-view>
</template>
export class App {
message = 'Hello World!';
configureRouter(config, router) {
config.map([{
route: [""],
moduleId: "./blank",
redirect: "#/page"
},{
route: "page",
moduleId: "./page"
}])
}
}
<template>
</template>
export class Blank {
}
<template>
Child Child
</template>
export class ChildChild {
}
<template>
Child With Param
Param: ${paramString}
</template>
export class ChildWithParam {
activate(params){
this.paramString = params.str;
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
<template>
<h3>Child Main Page</h3>
<router-view></router-view>
<br><br>
<input type="text" value.bind="paramString" />
<button click.delegate="submitText()">Submit</button>
<br><br>
<label>Send (check console): %</label>
<button click.delegate="submitText('%')">Submit</button>
<br><br>
<label>Send (Try me twice and check console): #$^#$113124!</label>
<button click.delegate="submitText('#$^#$113124!')">Submit</button>
<br><br>
<label>Send (Try me twice and check console): <>()</label>
<button click.delegate="submitText('<>()')">Submit</button>
<br><br>
<label>Encoding Uri doesn't help:</label>
<input type="text" value.bind="paramString" />
<button click.delegate="submitEncodedText()">Submit</button>
</template>
export class Page {
configureRouter(config, childRouter) {
config.map([{
route: "",
moduleId: "./child-child"
},{
route: "textSubmit/:str",
name: "textSubmit",
moduleId: "./child-with-param"
}]);
this.router = childRouter;
}
submitText(text) {
this.router.navigateToRoute("textSubmit", { str: text ? text : this.paramString });
}
submitEncodedText(): string {
this.router.navigateToRoute("textSubmit", { str:encodeURIComponent(this.paramString)
.replace(/\-/g, "%2D")
.replace(/\_/g, "%5F")
.replace(/\./g, "%2E")
.replace(/\!/g, "%21")
.replace(/\~/g, "%7E")
.replace(/\*/g, "%2A")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29")
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment