-
-
Save mttmccb/58589efed415a6cf3046b6d5d178b2c9 to your computer and use it in GitHub Desktop.
canDeactivate check
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>Another home</h1> | |
<p>The grass is not greener <a route-href="route: home">take me back</a>.</p> | |
</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 AnotherHome { } |
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> | |
<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 { | |
configureRouter(config, router) { | |
this.router = router; | |
config.title = 'Aurelia'; | |
config.map([ | |
{ route: ['', 'home'], name: 'home', moduleId: 'home' }, | |
{ route: 'another-home', name: 'anotherhome', moduleId: 'another-home' } | |
]); | |
} | |
} |
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>Home</h1> | |
<button click.trigger="moveHome()">Move Home</button> | |
<input checked.bind="canLeaveHome" type="checkbox"> Can leave home. | |
<p if.bind="navigationFailed">NOPE!</p> | |
</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
import { Router } from 'aurelia-router'; | |
import { inject } from 'aurelia-framework'; | |
@inject(Router) | |
export class Home { | |
navigationFailed = false; | |
canLeaveHome = false; | |
constructor(router) { | |
this.router = router; | |
} | |
canDeactivate() { | |
return this.canLeaveHome; | |
} | |
moveHome() { | |
this.router.navigateToRoute('anotherhome') | |
.then((navigated) => { | |
this.navigationFailed = navigated; | |
}); | |
} | |
} |
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://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment