This works fine for now with a url like test.com/#/album/0/the-slug-here, but I'm trying to achieve test.com/#/album/the-slug-here
<a ng-href="#/album/{{$index}}/{{project.slug}}">{{project.title}}</a>
(function() {
var app = angular.module('chp', ['ngRoute', 'projectControllers']);
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/directory.html',
controller: 'ProjectsCtrl'
}).
when('/album/:id', {
templateUrl: 'partials/album.html',
controller: 'ProjectDetailCtrl'
}).
when('/album/:id/:slug', {
templateUrl: 'partials/album.html',
controller: 'ProjectDetailCtrl'
}).
otherwise({
redirectTo: '/'
});
}]);
var projectControllers = angular.module('projectControllers', []);
projectControllers.controller('ProjectsCtrl', ['$scope', '$http',
function ($scope, $http) {
$scope.projects = albums;
$scope.filters = { };
}]);
projectControllers.controller('ProjectDetailCtrl', ['$scope', '$routeParams', '$sce',
function($scope, $routeParams, $sce) {
$scope.project = albums[$routeParams.id];
}]);
When I remove the id though and try to just link to the slug, it's not loading in the data. The only way I've gotten to work so far is by adding the 2nd route which includes both. Any way to get rid of the index in the url?
/album/:slug? It just works fine to me plnkr.co/edit/9iYnxUmyVL0DupVZWpLC?p=preview