如何将外部链接添加到Angular SPA菜单?

时间:2016-11-07 11:01:43

标签: javascript angularjs hottowel

我正在使用角度hottowel模板来开发我的Web应用程序。如下所示的路由配置代码文件。

(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: {}
            }
        }
    ];
}})();

我需要在菜单中添加外部链接,例如www.google.com。如何添加另一个链接到此路由配置,如贝娄。

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

1 个答案:

答案 0 :(得分:0)

这个问题看起来类似于这个帖子看看 Using $routeProvider to redirect to routes outside of Angular