Comments (3)
The prefix is managed by $location service itself, it is not $routeSegment's responsibility. Moreover, links can be rewritten by the application or Angular itself, using its own knowledge about application configuration. It is all about separation of concerns.
from angular-route-segment.
I understand that.
The problem is that the URLs returned by your filters still need to work.
Without prefixing. They do not.
Currently, your filters only output the following :
define [
'lodash'
'angular'
'text!./common/templates/one.tpl.html'
'text!./common/templates/two.tpl.html'
'angular-route-segment'
], (_, angular, tplOne, tplTwo) ->
angular.module 'app.routes', [
'ngRoute'
'route-segment'
'view-segment'
]
.config [
'$routeSegmentProvider'
'$routeProvider'
'$locationProvider'
($routeSegmentProvider, $routeProvider, $locationProvider) ->
$locationProvider.html5Mode false
$locationProvider.hashPrefix "!"
$routeSegmentProvider
.when '/one', 'one'
.segment 'one',
template: tplOne
.when '/two', 'two'
.segment 'two',
template: tplTwo
$routeProvider.otherwise
redirectTo: '/'
]
<a href="{{ 'one' | routeSegmentUrl }}">Some Segment</a>
results in
<a href="/one">Some Segment</a>
This is fine if your backend is handling all the redirects, except that :
...
($routeSegmentProvider, $routeProvider, $locationProvider) ->
$locationProvider.html5Mode false
$locationProvider.hashPrefix "!"
...
Meaning, there isn't, so it doesn't, therefore all urls generated by the filter/service should include the required characters to make it work under those configured circumstances.
from angular-route-segment.
routeSegmentUrl
filter is just a wrapper around $routeSegment.getSegmentUrl()
. If it was returning an URL with a hash, then this would not work:
$location.path($routeSegment.getSegmentUrl('one'));
You have to either rely on core Angular logic for rewriting html5 URLs in legacy hashbang mode (see "Html5 links rewriting" section at this docs page), implement your own URL rewrite logic, or just write like that:
<a href="#!{{ 'one' | routeSegmentUrl }}">Some Segment</a>
from angular-route-segment.
Related Issues (20)
- Controllers are loaded that have same prefix HOT 1
- with multiple segment, updating parent scope works, but gets destroyed on reloading the parent url?
- Documentation Website offline?! HOT 1
- Doesnt work with ng-animate-ref?
- Require JS Compatibility
- reloadOnSearch false, doesn't work HOT 1
- Memory Leak: Watchers are not torn down properly on route change HOT 4
- Access controller from params
- watcher doesn't recreate children segments
- NPM package has no link to this repo
- Pass Data From one page to another without using route params
- disallow route change until the 'resolve' will not be resolved HOT 1
- Multiple otherwise
- How do i redirect to the previous route inside resolveFailed HOT 1
- Using query strings
- Support route parameter regular expressions
- Resolve/inject not working with angular 1.5 component
- It is not working with Angular 1.6.2 HOT 2
- BaseURL & image href on the same root
- There is no minified file in the bower_component folder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-route-segment.