I'm trying to routing to my html file but nothing happen when I click on the navigation to link to the page given (page 1, page 2 and page 3,and no console error either. I'm using my local server via command prompt. My app is specified in the html tag - html ng-myApp. I have looked at the similar question on this site but can't figure it out why not working. Thank you for your help.
here's navbar:
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header"> <a class="navbar-brand" href="#/">Logo</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="#/">Page1</a></li>
<li><a href="#/">Page2</a></li>
<li><a href="#/">Page3</a></li>
</ul>
</div>
</div>
</nav>
Here is the pages which will be displayed in ng-view withing index.html
Page1.html
<div>
<h1>{{titlePage1}}</h1>
</div>
Page2.html
<div>
<h1>{{titlePage2}}</h1>
</div>
Page3.html
<div>
<h1>{{titlePage3}}</h1>
</div>
Controller.js
angular.module('RouteControllers', [])
.controller('firstController', function($scope) {
$scope.firstTitle = "First page is Blue"
})
.controller('secondController', function($scope) {
$scope.secondTitle = "Second page is White"
})
.controller('thirdController', function($scope) {
$scope.thirdTitle = "Third page is Orange"
});
App.js
angular.module("myApp", ["ngRoute", "RouteControllers"]);
angular.module("myApp").config(function($routeProvider) {
$routeProvider.when("/", {
template: "<div main-slide-show></div>"<!--This is background template please ignore it -->
})
.when("/page1", {
templateUrl : "templates/page1.html",
controller : "firstController"
})
.when("page2", {
templateUrl : "templates/page2.html",
controller : "secondController"
})
.when("page3", {
templateUrl : "templates/page3.html",
controller : "thirdController"
});
<div ng-view></div>to your htmlangular.module('RouteControllers', [])change this toangular.module('myApp').controller