-
-
Save MT-PL-SWF-Dev/2e0ff35d2e08641448e536d639e31a12 to your computer and use it in GitHub Desktop.
Aurelia Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h1>Main Page</h1> | |
<router-view></router-view> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
message = 'Hello World!'; | |
configureRouter(config, router) { | |
config.map([{ | |
route: [""], | |
moduleId: "./blank", | |
redirect: "#/page" | |
},{ | |
route: "page", | |
moduleId: "./page" | |
}]) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Blank { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
Child Child | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ChildChild { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
Child With Param | |
Param: ${paramString} | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ChildWithParam { | |
activate(params){ | |
this.paramString = params.str; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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