Create a simple multi-page application using AngularJS routing

<!DOCTYPE html>
<html ng-app="routingApp">
<head>
    <title>AngularJS Routing</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.0/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.0/angular-route.min.js"></script>
</head>
<body>
    <ng-view></ng-view>

    <script>
        var app = angular.module('routingApp', ['ngRoute']);
        app.config(function($routeProvider) {
            $routeProvider
                .when('/', {
                    template: '<h1>Welcome to Home Page</h1>'
                })
                .when('/about', {
                    template: '<h1>About Us</h1>'
                })
                .when('/contact', {
                    template: '<h1>Contact Us</h1>'
                })
                .otherwise({
                    redirectTo: '/'
                });
        });
    </script>
</body>
</html>

 

Post your Answer