0

Hi i have one little bit issue while routing the path using angular.js.I am explaining my code below.

app.js:

var GoFastoApp=angular.module('GofastoHome',['ngRoute']);
GoFastoApp.config(function($routeProvider) {
    $routeProvider
    .when('/',{
        templateUrl : 'view/home.html',
        controller  : 'homecontroller'
    })
    .when('/deptinfo',{
        templateUrl : 'view/info.html',
        controller  : 'infocontroller'
    })
    .when('/TimeTable',{
        templateUrl : 'view/time.html',
        controller  : 'timecontroller'
    })
    .when('/course',{
        templateUrl : 'view/course.html',
        controller  : 'coursecontroller'
    })
    .when('/subject',{
        templateUrl : 'view/subject.html',
        controller  : 'subjectcontroller'
    })
    .when('/hod',{
        templateUrl : 'view/hod.html',
        controller  : 'hodcontroller'
    })
    .when('/faculty',{
        templateUrl : 'view/faculty.html',
        controller  : 'facultycontroller'
    })
})

When i am typing the url oditek.in/Gofast/ on the address bar of browser the required page is coming but after getting the page the the address bar url is showing oditek.in/Gofast/#/ .Here i am getting the unwanted # with this url and need to remove this.Please help me to resolve this problem.

8
  • Did you turn on html5 mode? Commented Oct 1, 2015 at 11:52
  • 1
    Have a look at this answer Commented Oct 1, 2015 at 11:53
  • Did you enable html5Mode and define <base> as explained in that answer ? Are you still facing the issue ? What is the browser that you're testing this ? Commented Oct 1, 2015 at 11:55
  • @Arkantos : i am testing in google chrome. Can I write $routeProvider.html5Mode(true); in this file ? Commented Oct 1, 2015 at 11:58
  • @Arkantos : i did as per that answer but it is throwing some error. Commented Oct 1, 2015 at 12:05

1 Answer 1

2

You need to enable html5Mode and also specify the <base> URL value in your markup like below.

app.js

GoFastoApp.config(function($routeProvider, $locationProvider) {

    $locationProvider.html5Mode({
      enabled: true,
      requireBase: true
    });

   // remaining router config goes here
});

Usually it's preferred to have <base> inside your <head>, but if you have CSS & JS files outside of <head>, then add it at the bottom of your HTML page, probably after all CSS and JS files, before closing the <body>, define the baseURI like below.

<base href="/Gofast/">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.