Charge routes and segments conf from array of configuration objects

    var segments = {
      's1': {
        view: {
          templateUrl: 'templates/section1.html',
          controller: MainCtrl
        }
      },
      's1|home': {
        when: ['/section1'],
        view: {
          templateUrl: 'templates/section1/home.html'
        }
      },
      's1|itemInfo': {
        view: {
          templateUrl: 'templates/section1/item.html',
          controller: Section1ItemCtrl,
          dependencies: ['id']
        }
      },
      's1|itemInfo|tab1': {
        when: ['/section1/:id', '/section1/:id/X'],
        view: {
          templateUrl: 'templates/section1/tabs/tab1.html'
        }
      },
      's1|itemInfo|tab2': {
        when: ['/section1/:id/Y'],
        view: {
          templateUrl: 'templates/section1/tabs/tab2.html'
        }
      },
      's1|itemInfo|tab3': {
        when: ['/section1/:id/Z'],
        view: {
          templateUrl: 'templates/section1/tabs/tab3.html'
        }
      },
      's1|prefs': {
        when: ['/section1/prefs'],
        view: {
          templateUrl: 'templates/section1/prefs.html'
        }
      },
      's2': {
        when: ['/section2'],
        view: {
          templateUrl: 'templates/section2.html',
          controller: MainCtrl
        }
      },
      's2|itemInfo': {
        when: ['/section2/:id'],
        view: {
          templateUrl: 'templates/section2/item.html',
          dependencies: ['id']
        }
      },
      's3': {
        when: ['/section3'],
        view: {
          templateUrl: 'templates/section3.html'
        }
      },
      's1|invalidTemplate': {
        when: ['/invalid-template'],
        view: {
          templateUrl: 'this-does-not-exist.html',    // 404
          resolveFailed: {
            templateUrl: 'templates/error.html',
            controller: 'ErrorCtrl'
          }
        }
      },
      's1|invalidData': {
        when: ['/invalid-data'],
        view: {
          templateUrl: 'templates/section1/home.html',     // Correct!
          resolve: {
            data: function($q) {
              return $q.reject('ERROR DESCRIPTION');     // Failed to load data
            }
          },
          resolveFailed: {
            templateUrl: 'templates/error.html',
            controller: 'ErrorCtrl'
          }
        }
      },
      's1|slowDataSimple': {
        when: ['/slow-data'],
        view: {
          templateUrl: 'templates/section1/slow-data.html',
          controller: 'SlowDataCtrl',
          resolve: {
            data: function($timeout, loader) {
              loader.show = true;
              return $timeout(function() { return 'SLOW DATA CONTENT'; }, 2000);
            }
          }
        }
      },
      's1|slowDataLoading': {
        when: ['/slow-data-loading'],
        view: {
          templateUrl: 'templates/section1/slow-data.html',
          controller: 'SlowDataCtrl',
          resolve: {
            data: function($timeout) {
              return $timeout(function() { return 'SLOW DATA CONTENT'; }, 2000);
            }
          },
          untilResolved: {
            templateUrl: 'templates/loading.html'
          }
        }
      },
      's1|inlineParent': {
        view: {
          templateUrl: 'templates/section1/inline-view.html'
        }
      },
      's1|inlineParent|inlineChildren': {
        when: ['/inline-view'],
        view: {
          // no template here
          controller: 'SlowDataCtrl',
          resolve: {
            data: function($timeout) {
              return $timeout(function() { return 'SLOW DATA CONTENT'; }, 2000);
            }
          },
          untilResolved: {
            templateUrl: 'templates/loading.html'
          }
        }
      },
      's1|itemInfo|tabSlow': {
        when: ['/section1/:id/slow'],
        view: {
          templateUrl: 'templates/section1/slow-data.html',
          controller: 'SlowDataCtrl',
          resolve: {
            data: function($timeout) {
              return $timeout(function() { return 'SLOW DATA CONTENT'; }, 2000);
            }
          },
          untilResolved: {
            templateUrl: 'templates/loading.html'
          }
        }
      }
    };

    $routeSegmentProvider.options.autoLoadTemplates = true;
    $routeSegmentProvider.chargeSegments (segments);
    $routeProvider.otherwise ({redirectTo: '/section1'});