0

我有 Home Accounts Services Orders Tickets 点击帐户的导航栏,有下拉字段新客户搜索客户点击新客户时,它应该导航到主页组件。

根组件视图:

<div class="dropdown">
    <a class="dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
        <span class="tab_ico fa fa-user"></span>
        <span class="tab_name">ACCOUNTS</span>
        <span class="caret_holder"><span class="caret"></span></span>
    </a>
    <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
        <li><a href="#"><span class="tab_ico fa fa-search"></span> Search customer</a></li>
        <li><a ng-link="['Home']"><span class="tab_ico fa fa-user"></span> New customer</a></li>
    </ul>
</div>

如您所见 ng-link="['Home']"

路由配置:

$routeConfig: [  
    { path: "/dashboard", component: "dashboard",name:"Dashboard",useAsDefault: true },  
    { path: "/home", component: "home", name:"Home" },  
    { path: "/account", component: "account", name:"Account" },  
    { path: "/**", redirectTo: ["Home"] }  
],  

家庭组件

angular.module('app.home').component("home", {
    templateUrl: "app/components/home/homeview.html",

    controllerAs: "model",
    controller: function($scope, dataservice) {
        var vm = this;
        console.log("entered into home component");

    }
})

主页组件视图

<div>
    <ul>
        <li><span class="tab_ico fa fa-search"></span> SEARCH CUSTOMER <span class="closetab">x</span></li>
        <li class="k-state-active"><span class="tab_ico fa fa-user"></span> Identification <span class="closetab">x</span></span></li>
    </ul>
</div>

单击新客户时,它应该显示主页组件视图,但它不显示主页组件视图?,也没有错误。!!

4

1 回答 1

0

您可以使用不ngLink带.<a>href

代替

<a href="#" ng-link="['Home']"><span class="tab_ico fa fa-user"></span> New customer</a>

用这个

<a ng-link="['Home']"><span class="tab_ico fa fa-user"></span> New customer</a>

我认为这href可能是这里的问题。

来源Angular 路由器文档

于 2016-08-22T08:24:43.600 回答