npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hackages/ngx-routing-history

v0.0.2

Published

A provider for routing history

Downloads

57

Readme

Build Status npm



Overview

Why use ngx-routing-history, how to install and use.

What is it?

A provider for routing history.

Check out the documentation below.

Installation

yarn add @hackages/ngx-routing-history

# OR

npm i @hackages/ngx-routing-history

Setup

Just add ngx-routing-history to your module & setup the RouterModule like this for example:

AppRoutingModule

const APP_ROUTES: Route[] = [
  {
    path: 'home',
    component: HomeComponent
  },
  {
    path: 'detail',
    component: DetailComponent
  },
  {path: '**', redirectTo: 'home'}
];

@NgModule({
  imports: [RouterModule.forRoot(APP_ROUTES)],
  exports: [RouterModule]
})
export class AppRoutingModule {}

AppModule

import { NgxRoutingHistoryModule } from '@hackages/ngx-routing-history';

@NgModule({
  imports: [
    AppRoutingModule,
    NgxRoutingHistoryModule
  ]
})

Documentation

ngx-routing-history

ngx-routing-history provides you 7 functions which will help you manage your history

ngx-routing-history #loadRouting

This function need to be used in your root component. It will begin the record of your navigation in your website

export class AppComponent {
  constructor(routingHistory: NgxRoutingHistoryProvider) {
    routingHistory.loadRouting();
  }
}

ngx-routing-history #getHistory

getHistory will give you an array with all your routing history

ngx-routing-history #getUrlByIndex

with getUrlByIndex you need pass in argument the index of the route you want get in the history stack

getUrlByIndex(index);

ngx-routing-history #getCurrentUrl

with getCurrentUrl you get the current route url

ngx-routing-history #getPreviousUrl

with getPreviousUrl you get the previous route url

ngx-routing-history #go

this function will just pass the url in parameter to the router navigate function

ngx-routing-history #back

the back function take an object with two possible key the first is an url you can give and if you have it in your stack that will clean every route in the stack after the route pass. If you pass nothing that you just take the previousUrl.

The second key in the object is defaultRoute, you can use this one if you want a backup route if there is no route in the history stack

export class DetailComponent implements OnInit {
  public previousRoute: string;
  constructor(private routingHistory: NgxRoutingHistoryProvider) {}

  ngOnInit() {
    this.previousRoute = this.routingHistory.getPreviousUrl();
  }

  back() {
    this.routingHistory.back({url: this.previousRoute, defaultRoute: '/home'});
  }
}

Contributing

Please see the contributing guidelines.