0

假设我有一个包含 3 个不同页面的应用程序

第 1 页 - 模板 1

第 2 页 - 模板 1

第 3 页 - 模板 2

第 4 页 - 模板 2

我想对第 1 + 2 页使用相同的模板,对第 3 + 4 页使用相同的模板。

所以我想到了这样的事情:在 index.html 我有

<body class="body" data-ng-show="is_index"></body>
<body class="body" data-ng-hide="is_index"></body>

我正在设置is_index$routeChangeSuccess

.controller('app', ['$scope','$route','$location',function($scope,$route,$location){
    $scope.$on("$routeChangeSuccess",function($currentRoute,$previousRoute ){

        if ($route.current.title == 'page1')
        {
            $scope.is_index = true;
        }
        else if ( $route.current.title == 'page2')
        {
            $scope.is_index = true;
        }
        else if ( $route.current.title == 'page3')
        {
            $scope.is_index = false;
        }
    });

好吧,这不起作用,我在设置 is_index 之前加载了正文。

如果您有任何想法,请告诉我我应该如何正确地做到这一点。

4

0 回答 0