Kieran Wild
Kieran Wild

Reputation: 71

Spring Boot/Angular app. routing a completely self contained HTML file

This might seem strange but I basically want to create a HTML file that is not in anyway associated to the angular/spring boot app.

Currently:

What I want:

I am very new to angular and Spring so even just guiding me in the right direction would be a huge help.

Thanks.

Upvotes: 0

Views: 98

Answers (1)

unknowncodder
unknowncodder

Reputation: 246

You should use ngRoute.By the courtesy of "ngRoute" you can redirect user to specific views by the specific urls. Pls make some research about it. Let's assume you solve your view and redirect issues. How you gonna fetch data from server side? At this time I suggest you to look at service and factory objects. Hope it helps.

Sample code :

// create the module and name it exApp
// also include ngRoute for all our routing needs

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

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

        // route for the home page
        .when('/', {
            templateUrl : 'pages/home.html',
            controller  : 'mainController'
        })

        // route for the about page
        .when('/about', {
            templateUrl : 'pages/about.html',
            controller  : 'aboutController'
        })

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

// create the controller and inject Angular's $scope
exApp.controller('mainController', function($scope) {
    // create a message to display in our view
    $scope.message = 'Everyone come and see how good I look!';
});

exApp.controller('aboutController', function($scope) {
    $scope.message = 'Look! I am an about page.';
});

exApp.controller('contactController', function($scope) {
    $scope.message = 'Contact us! JK. This is just a demo.';
});

Upvotes: 1

Related Questions