when i want to get to
http://www.koran-auf-deutsch.de/koran-deutsch/23-die-glaubigen-al-mominun/
and just enter
http://www.koran-auf-deutsch.de/koran-deutsch/23
i get directly to the url. i would like to get a similar behaviour in my angular app, where would you inject that functionality? any ideas?
angular.module('app', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/:id', {controller: RedirectCtrl}).
when('/:id/:title', {templateUrl: 'partials/post.html', controller: PostCtrl}).
otherwise({redirectTo: '/404'});
}]);
function RedirectCtrl($routeParam, $http) {
var post_id = $routeParams.id;
// get title by id
$http.get('/api_url_to_get_title_by_id').success(function (data) {
window.location = "/" + post_id + "/" + data.title;
});
}
RedirectCtrl.$inject = ['$routeParams', '$http'];