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 🙏

© 2026 – Pkg Stats / Ryan Hefner

angular-ui-router-hooks-before-state

v0.0.3

Published

angular-ui-router hook to execute logic before loading a state, possibly changing destination state

Readme

UI-Router-Hooks-Before-State

Build Status Code Climate

UI-Router-Before-State-Filter provides a convenient method of registering filter logic for execution before a state is loaded. These filters can be used to guard states with arbitrary logic.

Note: This library is under active development and is most definitely subject to change.

Getting Started

(1) Get UI-Router-Before-State-Filter by cloning and building this repository:

git clone [email protected]:tdg5/angular-ui-router-hooks-before-state.git
cd angular-ui-router-hooks-before-state
npm install
bower install

(2) Include angular-ui-router-hooks-before-state.js (or angular-ui-router-hooks-before-state.min.js) with your javascripts, after including Angular itself.

(3) Add 'ui.router.hooks.beforeState' to your main module's list of dependencies.

Usage

beforeState filters can be registered by adding a beforeState attribute to the data object of the state you want to perform filtering on. The value of the beforeState attribute can be a function, an injectable array, or an array of functions and injectable arrays. For example:

  ..
  data: function() { // Filtering logic },
  ..

  ..
  data: ['$state', function($state) { // Filtering logic requiring $state }],
  ..

  ..
  data: [
    function() { // Filtering logic },
    ['$state', function($state) { // Filtering logic requiring $state }]
  ]
  ..

It is important to keep in mind that child states prototypically inherit their parent state's data attribute. This means that child states will inherit beforeState filters from their ancestor states (though filters are only called once per state). However, if a child state declares it's own beforeState data property, it will override the parent state's beforeData property and only run the hooks declared for the child. This makes it easy to create states that bypass ancestor logic, but it also means that some care needs to be taken when the intention is to append a filter.

A beforeState filter can be used to redirect to another state by returning an object from the filter with a to property. The to property should identify the state to transition to. Any value available for to, params, or options are passed to $state.go allowing for full customization of the state transition. If only params are returned from the filter function then those params are merged with the current $state.params.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request