So, I use ngroute to redirect to other html pages. I got this from an online tutorial, but when I try to run it does not display a message or go to the page I need. For example, if I want to click on the main page in the navigation bar, it should redirect to the home page. If I want to redirect to the login page, it should go to the login page. I'm not sure what is wrong. enter code hereThis is what I have:
index.html
<!DOCTYPE html>
<html ng-app="homepageApp">
<head>
<meta charset="UTF-8">
<title>Quiz HomePage</title>
<link rel="stylesheet" href="cs/homepage.css">
<script src="lib/angular.js"></script>
<script src="js/home.js"></script>
<script type="text/javascript" src="i"></script>
</head>
<body ng-controller="mainController">
<h1>Welcome To The Online Quiz Management</h1>
<div id="navigationBar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li style="float: right"><a href="#login">Login</a></li>
</ul>
</div>
<div ng-view></div>
</body>
</html>
home.js
var app = angular.module("homepageApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/homepage", {
templateUrl: "homepage.html",
controller: "mainController"
})
.when("/login", {
templateUrl: "login.html",
})
.when("/about", {
templateUrl: "about.html",
controller: "aboutController"
})
.when("/contact", {
templateUrl: "contact.html",
controller: "contactController"
});
});
app.controller("mainController", function($scope) {
$scope.message = 'Everyone come our homepage';
});
app.controller("loginController", function($scope) {
});
about.html
<!DOCTYPE html>
<html ng-app="homepageApp">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<h1>About Page</h1>
<p>{{ message }}</p>
</body>
</html>
source
share