0

我是 Angular 新手,我尝试让子菜单正常工作。在每个控制器中,我使用 $rootScope 来应用视图的实际子菜单。显示菜单,但不会在视图更改时更新:

仪表板控制器:

controller('DashboardCtrl', function DashboardCtrl ( $scope , $rootScope, restService, $location, $routeParams) {
    $rootScope.submenu = [{
        name: "link1",
        link: "/#/link1"
    },{
        name: "link2",
        link: "/#/link2"
    }];
});

文章控制器:

controller('ArticleCtrl', function ArticleCtrl ( $scope , $rootScope, restService, $location, $routeParams) {
    $rootScope.submenu = [{
        name: "link1",
        link: "/#/link1"
    },{
        name: "link2",
        link: "/#/link2"
    }];
});

我想我错过了什么。有人可以告诉我一个可行的解决方案吗?

谢谢

4

0 回答 0