Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

angular-named-route

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angular-named-route

named route support for angular-route


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Build Status

Angular named route

Named route support for angular-route. Name your routes so you don't have to copy-paste-replace url everywhere.

Install

bower install angular-named-route --save

or just grab dist/angular-named-route.js

Usage

//include it in your app
angular.module('myapp', ['ngRoute', 'ngNamedRoute']);

//provide names to routes
angular.module('myapp').config(function($routeProvider) {
    $routeProvider.
      when('/', {
        controller: 'HomeCtrl',
        name: 'home'
      }).
      when('/thing/:id', {
        controller: 'ThingCtrl',
        name: 'thing-detail'
      });
});

//use as a service
angular.module('myapp').controller('ThingCtrl', function (namedRouteService, $location) {
    var path;
    
    //reverse to get path string
    path = namedRouteService.reverse('home'); 
    //path = '/'

    //single param
    path = namedRouteService.reverse('thing-detail', 1); 
    //path = '/thing/1'

    //param list
    path = namedRouteService.reverse('thing-detail', [1]); 
    //path = '/thing/1'

    //param object
    path = namedRouteService.reverse('thing-detail', {id: 1}); 
    //path = '/thing/1'

    //open immediately
    namedRouteService.open('thing-detail', 1);
    //is same as
    $location.path(namedRouteService.reverse('thing-detail', 1));
});

'named-route' directive to set href attribute:

<a named-route="'home'">home</a>

<a named-route="'thing-detail'" route-params="1">first thing</a>

<a named-route="'thing-detail'" route-params="{id: 1}">first thing</a>

Development

Install

npm install gulp-cli -g
npm install

Build

gulp build

Test

npm test

Keywords

FAQs

Last updated on 17 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc