Arjun Hegde Arjun Hegde - 5 months ago 14
AngularJS Question

How to give href for angularjs routes

I am new to Angular.js and Im currently trying to learn about ngRoute, but its not displaying anything

This is app.js config file

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

// configure our routes
app.config(function($routeProvider) {

// route for the home page

.when('/', {
templateUrl : 'index.html',
controller : 'mainController'

// route for the about page
.when('/about', {
templateUrl : 'bb.html',
controller : 'loginController'

// route for the contact page
.when('/contact', {
templateUrl : 'contact.html',
controller : 'contactController'

This is main index.html

<link href="css/bootstrap.min.css" rel="stylesheet" media="screen" />
<link href="css/bootstrap-theme.min.css" rel="stylesheet" media="screen"/>

<script src=""></script>

<script src=""></script>

<body ng-app="myApp">

<h1> User :{{user}}</h1>

<a href="#about">

<h1>User :{{user}}</h1>


<script src="app.js"></script>

<script src="mainController.js"></script>
<script src="loginController.js"></script>

These are my controllers

app.controller('mainController',function($scope, $http) {

$scope.user = "user";
app.controller('loginController',function($scope, $http) {

$scope.user = "user";


This is

When I click on about, it gives CANNOT GET /about, because it checks for node routes..How should I give the href for about?


Because you have ng-app = "blog" in your html and you have angular.module("myApp",['ngRoute']); in your js