2015-07-04 72 views
1

我有一個Django和Angular的項目。重定向到Django和Angular的索引

我有一個頁面位於http://localhost:8000/install/#/,這是安裝應用程序的一部分。在那裏我有一個按鈕,POST一個表單,然後我想我的控制器中的功能重定向到我的索引頁http://localhost:8000/

$http.post('install/send_install_form/', installation) //installation is a dictionary 
     .then(function(data){ 
      alert('You will be redirected') 
      setTimeout(function(){ 
        // REDIRECTION TO THE INDEX..? 
       }, 
       4000 
      ) 
     }, 
     function(data){ 
      alert("Error") 
     }) 

我們如何使用Django-Angular連接應用程序和應用程序?

謝謝!

回答

1

重定向angularJS應用程序中:

scope.$apply(function() { 
    $location.path("/route"); 
}); 

重定向angularJS應用外:

window.location.replace('http://google.ca/'); 
+0

那我重定向到http://本地主機:8000 /安裝/#/代替。 –

+0

其實,這個效果很好: window.location.replace('/'); 謝謝! –