Aurelia Tutorial
Aurelia Useful Resources
Selected Reading
- Aurelia - Best Practices
- Aurelia - Community
- Aurelia - Debugging
- Aurelia - Bundling
- Aurelia - Tools
- Aurelia - Localization
- Aurelia - Dialog
- Aurelia - Animations
- Aurelia - History
- Aurelia - Routing
- Aurelia - Refs
- Aurelia - HTTP
- Aurelia - Forms
- Aurelia - Event Aggregator
- Aurelia - Events
- Aurelia - Converters
- Aurelia - Binding Behavior
- Aurelia - Data Binding
- Aurelia - Plugins
- Aurelia - Configuration
- Aurelia - Dependency Injections
- Aurelia - Custom Elements
- Aurelia - Component Lifecycle
- Aurelia - Components
- Aurelia - First Application
- Aurelia - Environment Setup
- Aurelia - Overview
- Aurelia - Home
Aurelia Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Aurelia - History
Aurepa - History
In this chapter, you will learn how to use aurepa-history plugin.
Step 1 - Install the Plugin
This plugin is already available as a part of the standard configuration. If you have set aurepa.use.standardConfiguration() as a part of a manual configuration, you are ready to go.
main.js
export function configure(aurepa) { aurepa.use .standardConfiguration() .developmentLogging(); aurepa.start().then(() => aurepa.setRoot()); }
Step 2 - Using the History
We will use an example from the last chapter (Aurepa - Routing). If we want to set the functionapty for navigating back or forward, we can use the history object with back() and forward() methods. We will add this after a router configuration.
app.js
export class App { configureRouter(config, router) { config.title = Aurepa ; config.map([ { route: [ , home ], name: home , moduleId: ./pages/home/home , nav: true, title: Home }, { route: about , name: about , moduleId: ./pages/about/about , nav: true, title: About } ]); this.router = router; } goBack() { history.back(); } goForward() { history.forward(); } }
Now, let s add two buttons to our view.
app.html
<template> <nav> <ul> <p repeat.for = "row of router.navigation"> <a href.bind = "row.href">${row.title}</a> </p> </ul> </nav> <button cpck.delegate = "goBack()"></button> //The button used for navigationg back... <button cpck.delegate = "goForward()"></button> //The button used for navigationg forward... <router-view></router-view> </template>
The users can navigate back and forward by cpcking the buttons we added.
Advertisements