Aleks_Saint
Aleks_Saint

Reputation: 67

Routing in Angular

How can I organize the following code in a way that I can only get template.html and not the template1.html?

App.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
  $locationProvider.html5Mode({
    enabled: true,
    requireBase: false
  });
  $routeProvider
    .when('/', {
      templateUrl: "template/home.html",
      controller: "homeCtrl"
    })
    .when('/artist', {
      templateUrl: "template/artist.html",
      controller: "artistCtrl"
    })
    .when('/:collectionId', {
      templateUrl: "template/template.html",
      controller: "templateCtrl"
    })
    .when('/:trackId', {
      templateUrl: "template/template1.html",
      controller: "templateCtrl"
    })
    .otherwise({
      redirectTo: "/"
    });
}]);

Thank you for your help!

Upvotes: 1

Views: 58

Answers (1)

Andreas Therkildsen
Andreas Therkildsen

Reputation: 64

You should rename your routes.

.when('/collection:id', {
    templateUrl: 'your/template.html',
    controller: 'yourController'
  });
})

Upvotes: 1

Related Questions