2014-09-01 21 views
0

我目前在angularJS中遇到了一些路由錯誤。如何在IE瀏覽器的angularJS中路由頁面?

我的代碼是這樣的:使用location.href = "/#/evaluate"$(location).attr('href', "/#/evaluate")可以路由到其他頁面的第一次點擊,但在第二

控制器

$scope.classCode = []; 

    var userId = localStorageService.get('userId'); 
    //$scope.CurrentModule = sharedService.getCurrentModule(); 
    EvaluationService.getClassCode(userId).then(function (results) { 
     $scope.classCode = results.data; 
    }); 

    $scope.redirectViews = function (classCode, enrollCode, isValid) { 
     if (!isValid) { 
      localStorageService.set('currentClassCode', classCode); 
      localStorageService.set('currentEnrollCode', enrollCode); 

      //location.href = "/#/evaluate"; 

      $window.location.href="#/evaluate"; 

      //$("a[href='#/evaluate']").click(); 

      //$(location).attr('href', "/#/evaluate"); 

     } 
    }; 

應用

app.config(function ($routeProvider) { 
    $routeProvider.when("/home", { 
     controller: "homeController", 
     templateUrl: "templates/home.html" 
    }); 

    $routeProvider.when('/evaluations', { 
     controller: 'EvaluationController', 
     templateUrl: 'Projects/Evaluation/templates/evaluation.html' 
    }); 
    $routeProvider.when('/evaluate', { 
     controller: 'CriteriaController', 
     templateUrl: 'Projects/Evaluation/templates/evaluate.html' 
    }); 
    $routeProvider.when("/login", { 
     controller: "loginController", 
     templateUrl: "login.html" 
    }); 

    $routeProvider.otherwise({ redirectTo: '/home' }); 
}); 

點擊鏈接將會循環遍歷使用$("a[href='#/evaluate']").click()使用$window.location.href("#/evaluate")不會路由到其他模板,但在整個我的控制器,並再次得到一個錯誤循環..

我的控制器,並得到一個錯誤..

沒有響應..沒有路,也沒有環

爲什麼我有這樣的錯誤在IE Browser但是當我使用ChromeFirefox它使用我的原始代碼是$window.location.href("#/evaluate")

是任何一個跑這麼細有一個想法如何angularJS路線,無論是什麼用戶將使用瀏覽器?

+0

什麼版本的IE? – Jai 2014-09-01 06:55:49

+0

我使用IE v10 .. – 2014-09-01 06:58:46

回答

0

能否請您嘗試使用以下格式(即不帶 「#/」)

$location.path('/evaluate'); 

    or 

    $location.path('/evaluate').replace(); 
+0

非常感謝。..有一篇文章,我沒有讀過他/她的名字是,你做了第一篇文章.. coz他/她得到了與你一樣的答案,但它的我的錯我沒有注意到錯誤,但無論如何,再次感謝 – 2014-09-01 07:39:33

相關問題