Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using MVC Web API and Angular JS

When i am giving single routeProvider, then its working after adding one more routeProvider its not working....

My Code Is:

   var phoneModelsApp = angular.module('phoneModelsApp', ['ngRoute']);

   phoneModelsApp.config(['$routeProvider', 
   function ($routeProvider) {    


  $routeProvider.when('/phonelist', {
      templateUrl: 'partials/Test1.html',
      controller: 'phoneListCtrl'
  }).
 $routeProvider.when('/phonelist1', {
     templateUrl: 'partials/Test2.html',
     controller: 'phoneListCtrl'
 }).       
    otherwise({
        redirectTo: '/phonelist'
    });
  }]);
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You need to add to in your urls "#" or adding in your configuration:

$locationProvider.html5Mode(true);

In order to remove the # in Angular you need to make an small change in your configuration:

You need to add:

$locationProvider.html5Mode(true);

This is the whole version:

myApp.config(function($routeProvider, $locationProvider) {
  $locationProvider.html5Mode(true);
  $routeProvider
    .when('/page1', { template: 'page1.html', controller: 'Page1Ctrl' })
    .when('/page2', { template: 'page2.html', controller: 'Page2Ctrl' })
});
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.