Routing issue in Angular (happening a "!" in URL)


I’m using Angular ngRoute.

When I’m trying to route to another page, it is not redirecting in URL. It shows as http://localhost:58317/#!#%2Fstudents


var app = angular.module('MyApp', ['googlechart', 'ngRoute'])
app.controller('HomeCtrl', function ($scope) {
    $scope.msg = "Hello Angular.....";

app.config(function ($routeProvider, $locationProvider) {
    $routeProvider.when("/home", {
        templateUrl: '/Home/part1',
        controller: 'routeDemoFirstController'
    when('/contact', {
        templateUrl: '/Home/part2',
        controller: 'routeDemoSecondController'
     when('/students', {
         templateUrl: '/Home/part2',
         controller: 'routeDemoSecondController'

This is my .cshtml code Here i write anchor tag

<div class="row">
        <a href="/#/home">Home</a>
        <a href="#/contact">Courses</a>
        <a href="#/students">Students</a>


You are using the hash-bang prefix:


It signicates that your URL should be:

<a href="#!/home">Home</a>

If you want to remove the ! from the URL (you can also remove the #), you can check this answer.

Answered By – Mistalis

Answer Checked By – Mary Flores (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.