angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.82k stars 27.5k forks source link

Get hashPrefix from $location #15683

Open mosermanuel opened 7 years ago

mosermanuel commented 7 years ago

Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug? feature

What is the current behavior? Currently, there is no possibility to read the hashPrefix outside of a config-block. So the application needs an own implementation to get the configured hashPrefix in for example a controller or service.

What is the expected behavior? It would be nice to get a (readonly) property on $location to get the hashPrefix.

What is the motivation / use case for changing the behavior? With the property it is possible to access the hashPrefix without any calculation.

Which versions of AngularJS, and which browser / OS are affected by this issue? Did this work in previous versions of AngularJS? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions. 1.6.0 and higher

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Thx!

Narretz commented 7 years ago

When do you need to programmatically access the hash prefix? I.e. what's the use case?

gkalpak commented 7 years ago

I don't think this is a common need and since it is totally (and easily) feasible outside core, it's 👎 from me.

mosermanuel commented 7 years ago

Thx for the response!

The concrete use case is writing a library in which we do not know the hashPrefix set by the developer (config-block of the application is done after the config-block of the depending libraries). The library needs to interact with an embedding rich client, which has to set the route-paths as full fragment for interaction with the SPA (e.x. #!/page1 or in other applications #/page1). As the hashPrefix can differ, the library needs to calculate the full fragment from the url. The available routes are then communicated to the richt client so it can change the route via the browser-path of the current application.

Thx!