How to add external link to Angular SPA Menu?

826 Views Asked by At

I'm using angular hottowel template for develop my web application. route config code file shown bellow.

(function(){  
'use strict';

var app = angular.module('app');

// Collect the routes
app.constant('routes', getRoutes());

// Configure the routes and route resolvers
app.config(['$routeProvider', 'routes', routeConfigurator]);

function routeConfigurator($routeProvider, routes)
{
    routes.forEach(function(r)
    {
        setRoute(r.url, r.config);
    });

    $routeProvider.otherwise({ redirectTo: '/' });

    function setRoute(url, definition)
    {
        definition.resolve = angular.extend(definition.resolve || {}, {
            prime: prime
        });

        $routeProvider.when(url, definition);
    }
}

prime.$inject = ['datacontext'];
function prime(dc) { return dc.prime(); }

// Define the routes 
function getRoutes()
{
    return [
        {
            url: '/',
            config: {
                templateUrl: 'app/dashboard/dashboard.html',
                title: 'dashboard',
                settings: {
                    nav: 1,
                    content: '<i class="fa fa-dashboard"></i> Dashboard'
                }
            }
        }, {
            url: '/customers',
            config: {
                title: 'customers',
                templateUrl: 'app/customer/customers.html',
                settings: {
                    nav: 2,
                    content: '<i class="fa fa-calendar"></i> customers'
                }
            }
        },
        {
            url: '/customer/:id',
            config: {
                title: 'customer',
                templateUrl: 'app/customer/customerdetail.html',
                settings: {}
            }
        }
    ];
}})();

I need to add external link to my menu as example www.google.com. how can i add another link to this route config like bellow.

{
        url: 'www.google.com',
        config: {
            title: 'MyExternalLink',
            settings: {}
        }
    }
1

There are 1 best solutions below

2
Arvin On

This question looks similar to this post have a look Using $routeProvider to redirect to routes outside of Angular