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 🙏

© 2025 – Pkg Stats / Ryan Hefner

angular-ui-router-styles

v0.0.6

Published

angular-ui-router-styles ====================

Readme

angular-ui-router-styles

Build Status

This is a simple module for AngularJS that provides the ability to have route-specific CSS stylesheets, by integrating with Angular uiRouter.

What does it do?

It allows you to declare partial-specific or route-specific styles for your app using Angular's ui-router $stateProvider service. This solves that problem by allowing you to do something like this:

app.config(['$stateProvider', function($stateProvider){
    $stateProvider

      .state('state1', {
        url: '/state1',
        controller: 'State1controller',
        template: '<div ui-view></div>',
        data: {
          css: 'styles/custom-state1-override.css'
        }
      })

      .state('state1.state12', {
        url: '/:id',
        controller: 'State12Controller',
        templateUrl: 'views/my-template.html'
      })

      .state('state2', {
        url: '/state2',
        controller: 'State2Controller',
        templateUrl: 'views/another-template.html',
        data: {
          css: ['styles/custom-state2-override.css', 'another.css']
        }
      })
        // more states can be declared here
}]);

Note that state1.state12 will have the parent file styles/custom-state1-override.css injected; redefine the css array for override it.

How to install:

  • Install it with Bower via bower install angular-ui-router-styles --save

  • Ensure that your application module specifies uiRouterStyles as a dependency: angular.module('myApplication', ['uiRouterStyles'])

  • Add css file(s) relative path to the state data object

.state('state1', {
  url: '/state',
  controller: 'StateCtrl',
  templateUrl: 'views/my-template.html',
  data: {
    css: 'styles/some-overrides.css'
  }
})

Things to notice:

  • Specifying a css property on the route is completely optional. If the state doesn't have a css property, the service will simply do nothing for that route.
  • You can even have multiple page-specific stylesheets per state, where the css property is an array of relative paths to the stylesheets needed for that route.
  • If a parent state exists the data object is inherited.

This directive does the following things:

  • It compiles (using $compile) an html string that creates a set of tags for every item in the data.css state property using ng-repeat and ng-href.
  • It appends that compiled set of <link /> elements to the <head> tag.
  • It then uses the $rootScope to listen for '$stateChangeSuccess' events. For every '$stateChangeSuccess' event, it cleans all css appended before and adds the new css file(s) to the <head> tag if there are any.