Last active
October 7, 2016 17:33
-
-
Save mattduffield/f780cb1637bd61f0ba1510f935ce38c5 to your computer and use it in GitHub Desktop.
Aurelia Gist - getViewStrategy
This file contains hidden or 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>${title}</h1> | |
| <compose view-model="dynamic"></compose> | |
| </template> |
This file contains hidden or 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 { | |
| title = 'Dynamic Screens' | |
| } |
This file contains hidden or 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
| import {InlineViewStrategy} from 'aurelia-templating'; import {ViewService} from './view-service'; export class Dynamic { constructor() { } getViewStrategy() { let template = ` <template> <h2>Inside dynamic template!</h2> </template> `; let vs = new InlineViewStrategy(template, this); return vs; } } |
This file contains hidden or 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 hidden or 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
| /** * Provides view markup. * * @class ViewService */ export class ViewService { constructor() { this.views = []; this.initViews(); } getView(name) { return this.views.find((v) => { return v.name === name; }) } initViews() { this.views = [ { name: "simple", view: ` <template> <h2>Inside dynamic template!</h2> </template> ` }, { name: "data-entry", handlers: { submit: (result) => { this.settings = Object.assign( {}, this.settings, {'result': result}); // alert(result); this.close(true, this.settings); }, cancel: (result) => { this.close(false, result); } }, view: ` <template> <form role="form" submit.delegate="controller.handlers.submit(name)"> <legend>\$\{model.heading\}</legend> <div class="form-group"> <label for="fn">Action Name</label> <input type="text" value.bind="name" class="form-control" id="fn" placeholder="Action Name" attach-focus> </div> <div class="form-group"> <button type="submit" class="btn btn-primary"> Submit </button> <button type="button" class="btn btn-default" click.delegate="controller.handlers.cancel()"> Cancel </button> </div> </form> </template> ` } ]; } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment