<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src=
</script>
<script src=
</script>
<style>
body {
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
h1 {
color: green;
}
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h3>Single Page Application in AngularJS</h3>
<script type="text/ng-template" id="first.html">
<h1>First Page</h1>
<h2 style="color:green">
Welcome to GeeksForGeeks
</h2>
<h3>{{message}}</h3>
</script>
<script type="text/ng-template" id="second.html">
<h1>Second Page</h1>
<h2 style="color:green">
Start Learning With GFG
</h2>
<h3>{{message}}</h3>
</script>
<script type="text/ng-template" id="third.html">
<h1>Third Page</h1>
<h2 style="color:green">
Know about us
</h2>
<h3>{{message}}</h3>
</script>
<a href="#/">First</a>
<a href="#/second">Second</a>
<a href="#/third">Third</a>
<div ng-view></div>
<script>
var app = angular.module('myApp', []);
var app = angular.module('myApp', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'first.html',
controller: 'FirstController'
})
.when('/second', {
templateUrl: 'second.html',
controller: 'SecondController'
})
.when('/third', {
templateUrl: 'third.html',
controller: 'ThirdController'
})
.otherwise({ redirectTo: '/' });
});
// Controller is a JS function that maintains
// application data and behavior using $scope object
// properties and methods can be attached to the
// $scope object inside a controller function
app.controller('FirstController', function ($scope) {
$scope.message = 'Hello from FirstController';
});
app.controller('SecondController', function ($scope) {
$scope.message = 'Hello from SecondController';
});
app.controller('ThirdController', function ($scope) {
$scope.message = 'Hello from ThirdController';
});
</script>
</body>
</html>