{"id":15623709,"url":"https://github.com/justinsa/angular-navigation-service","last_synced_at":"2025-03-29T16:40:38.273Z","repository":{"id":18869860,"uuid":"22086835","full_name":"justinsa/angular-navigation-service","owner":"justinsa","description":"A navigation helper service for Angular client applications.","archived":false,"fork":false,"pushed_at":"2017-06-23T03:41:55.000Z","size":27,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-22T09:36:15.061Z","etag":null,"topics":["angular","angular-service","javascript","navigation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justinsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-22T01:43:35.000Z","updated_at":"2017-03-14T07:23:14.000Z","dependencies_parsed_at":"2022-07-28T23:18:55.765Z","dependency_job_id":null,"html_url":"https://github.com/justinsa/angular-navigation-service","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinsa%2Fangular-navigation-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinsa%2Fangular-navigation-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinsa%2Fangular-navigation-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justinsa%2Fangular-navigation-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justinsa","download_url":"https://codeload.github.com/justinsa/angular-navigation-service/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246215825,"owners_count":20741894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular-service","javascript","navigation"],"created_at":"2024-10-03T09:58:21.790Z","updated_at":"2025-03-29T16:40:38.248Z","avatar_url":"https://github.com/justinsa.png","language":"JavaScript","readme":"[![Bower version](https://badge.fury.io/bo/ng-navigation-service.svg)](https://github.com/justinsa/angular-navigation-service)\n[![NPM version](https://badge.fury.io/js/ng-navigation-service.svg)](https://www.npmjs.com/package/ng-navigation-service)\n![Master Build Status](https://codeship.com/projects/016878e0-603a-0133-c6e2-5a99c145e314/status?branch=master)\n[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/justinsa/angular-navigation-service/blob/master/LICENSE)\n\nA navigation helper service for Angular client applications.\n\n## Dependencies\n\n* AngularJS - http://angularjs.org\n* Lodash - http://lodash.com\n\n## Configurable Dependencies\n\n* ng-authentication-service - https://github.com/justinsa/angular-authentication-service\n\nThe ng-navigation-service was designed in tandem with the ng-authentication-service, but it is not a hard requirement. The configured security service must support the following API:\n\n  1. ```boolean isAuthenticated()```\n  2. ```[String] roles()```\n\n## Basic Setup\n\nAdd this module to your app as a dependency:\n```JAVASCRIPT\nvar app = angular.module('yourApp', ['navigation.service']);\n```\n\nConfigure a security service to use with the navigation provider:\n```JAVASCRIPT\napp.config(['$navigationProvider', function ($navigationProvider) {\n  $navigationProvider.configure({\n    securityService: '$authentication'\n  });\n}]);\n```\n\nInject $navigation as a parameter in declarations that require it:\n```JAVASCRIPT\napp.controller('yourController', function($scope, $navigation){ ... });\n```\n\n## Configuration Options\n\nTo override the default configuration options, configure the module with an options argument during application configuration and provide overrides for any of the following options.\n\n```JAVASCRIPT\napp.config(['$navigationProvider', function ($navigationProvider) {\n  $navigationProvider.configure({\n    activeLinkDecorator: undefined,\n    inactiveLinkDecorator: undefined,\n    securityService: undefined,\n    extensions: undefined,\n    roleToAudienceMapFunction: function (userRole) {\n      return userRole;\n    },\n    inAudienceValidationFunction: function (userRoles, audiences) {\n      var userAudiences = _.flatten(_.map(userRoles, this.roleToAudienceMapFunction));\n      return !_.isEmpty(userAudiences) \u0026\u0026 !_.isEmpty(audiences) \u0026\u0026\n        _.some(audiences, function (audience) { return _.includes(userAudiences, audience); });\n    }\n  });\n}]);\n```\n\n### extensions\n\nAll properties (own and inherited) of the extensions object will be available as native to the $navigation service API. The extensions object is applied using the [_.defaults(...)](https://lodash.com/docs/#defaults) method and cannot overwrite any of the existing API properties. This is intended to provide implementors with a way to add objects or functions that are application specific and should fall within the context of the navigation service to expose, e.g., a hash of link objects or a function to re-write links.\n\n## API\n\n### inAudience\n```JAVASCRIPT\n// returns true if the user is in any of the specified audiences\n$navigation.inAudience('X', 'Y', 'Z');\n\n// will flatten provided arrays that are one-level deep in the arguments list\n$navigation.inAudience('X', ['Y', 'Z'], ['A']) === $navigation.inAudience('X', 'Y', 'Z', 'A')\n```\n\n### isActiveLocation\n```JAVASCRIPT\n// returns true if the location is the current active location\n// the following will match any location that starts with the /dashboard route\n$navigation.isActiveLocation('/dashboard');\n\n// can also handle sub-routes using '/'\n// the leading '/' is optional\n$navigation.isActiveLocation('dashboard/user');\n```\n\n### decorateLink\n```JAVASCRIPT\n// $navigation.decorateLink(item, active, inactive);\n// returns the active decorator if the location is the current active location (see isActiveLocation).\n// returns the inactive decorator if the location is not the current active location.\n$navigation.decorateLink('/dashboard', 'active-item', undefined);\n\n// parameters @active and @inactive are optional and if set to a falsy value will be\n// overridden by the corresponding configuration values, if those are set:\n//   configuration.activeLinkDecorator\n//   configuration.inactiveLinkDecorator\n$navigation.decorateLink('/dashboard');\n```\n\n### goto\n```JAVASCRIPT\n// Navigate to a route and optionally push the current location to history.\n$navigation.goto(route, noHistory);\n```\n\n### back\n```JAVASCRIPT\n// Pop and navigate to the previous location from history.\n$navigation.back();\n```\n\n## Additional Methods\nThese methods were primarily implemented for testing or utility purposes, but they may be useful in special scenarios and are part of the exposed API.\n\n### getConfiguration\n```JAVASCRIPT\n// Get the configuration options\n$navigation.getConfiguration();\n```\n\n### tokenizePath\n```JAVASCRIPT\n// $navigation.tokenizePath(location);\n// returns an in-order array of lowercase tokens from a location string.\n// returns an empty array if no tokens are in the location string.\n// returns an in-order array of lowercase tokens from the current active location, if no location parameter is provided.\n$navigation.tokenizePath('/dashboard');\n\n// parameter @location is optional and if set to a falsy value will be\n// overridden by the value of ``$location.path()``.\n```\n\n## Development\nAfter forking you should only have to run ```npm install``` from a command line to get your environment setup.\n\nAfter install you have two gulp commands available to you:\n\n1. ```gulp js:lint```\n2. ```gulp js:test```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinsa%2Fangular-navigation-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustinsa%2Fangular-navigation-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustinsa%2Fangular-navigation-service/lists"}