2016-11-07 76 views
0

我使用角度hottowel模板來開發我的web應用程序。路由配置代碼文件如下圖所示。如何添加外部鏈接到Angular SPA菜單?

(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: {} 
     } 
    } 
+0

''加入 –

+0

協議將定位出.right? –

+0

Nikhil不工作 – Wella

回答

相關問題