artch/angular-route-segment

Feature: pass additional arguments.

Closed this issue · 1 comments

when used routeProvider, easily passing additional arguments to "$routeChangeStart" and "$ routeChangeSuccess". Something like this:

$routeProvider
      .when('/', {
        title: 'Additional parmeter',
        templateUrl: 'main.html',
        controller: 'MainCtrl'
      });

Now i have "routeSegmentChange" event, but nothing similar to "$routeChangeStart" and is not friendly how to receive these arguments. Maybe if you could pass arguments from the routeSegment "when" function to ngRoute "when".

artch commented

You can it pass to segment() instead of when():

$routeSegmentProvider.when('/', 'main');
$routeSegmentProvider.segment('main', {
  templateUrl: 'main.html',
  controller: 'MainCtrl',
  title: 'Additional parameter'
});

And fetch from the controller it like this:

mod.controller('MainCtrl', function($routeSegment) {
  console.log($routeSegment.chain[0].params.title); 
});