[英]How to add external link to Angular SPA Menu?
我正在使用角度熱毛巾模板來開發我的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: {}
}
}
這個問題看起來類似於這篇文章,看看使用$ routeProvider重定向到Angular之外的路由
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.