AngularJS:某些链接的路由只运行一次

时间:2017-09-12 16:21:32

标签: javascript angularjs ngroute

我试图将AngularJS 1.6用于我的网站,并使用ng-route进行路由(因为我并不真正了解ui-router)。 我的问题是我有很多链接和一个带参数的链接:

        .when("/", {
            templateUrl : "pages/indexView.html"
        })
        .when("/index", {
            templateUrl : "pages/indexView.html"
        })
        .when("/services", {
            templateUrl : "pages/services.html"
        })
        .when....
        .when("/teams/:team", {
            templateUrl : "pages/teams.html",
            controller : 'TeamsCtrl'
        })
        .otherwise({
            redirect: '/pages/404.html'
        });

控制器TeamsCtrl有一些带有参数"的条件:team" :

        $scope.team = $routeParams.team;

        if($scope.team == 'abc'){
            $scope.Subtitle = 'abc';
            $scope.Description = '';
        } else if ($scope.team == 'fgh'){
            $scope.Subtitle = 'fghfhs';
            $scope.Description = '';                
        } else if ...

问题在于,当我第一次登陆网站时,我可以点击"团队链接中的任何链接"它有效,但如果我点击任何其他链接,所有"团队的链接"不会运行任何东西(另一方面,其他链接仍然运行良好)。

Ps:链接如下:href ="#!services"对于普通链接和href ="#!teams / abc"对于"球队的链接"。

你知道什么可以提供这个bug吗? 你需要更多的东西来帮助我吗?

感谢。

0 个答案:

没有答案