Follow

Category: AngularJS

Implementing routing in a SPA using AngularUI Router

Posted on July 6, 2017 by in AngularJS

Introduction

In this blog, we’ll give you a rundown of how we’ve implemented routing in our single page project management tool – PineStem.

Routing is a process of navigating the user to the desired location based on the action they perform.
Maintaining the user’s navigation history is a major challenge while developing a single page application(SPA).
To overcome this problem, we implemented a simple stack based solution which only involves pushing and popping an object with required properties.

Demo

You can find the sample code and a demonstration in the Plunker here – https://plnkr.co/OnBe1bc9Q7h1tYBK1pSY?p=info

Implementation

For PineStem, we’ve used a popular routing plugin named AngularUI Router.
The idea behind our implementation is quite simple. We store the parameters that are required to navigate back to a particular state in an object and push it into an array.