0

下面是我的角碼查看未呈現,

MDIApp.controller("loginCtrl", function ($scope, $http,$location,$sce) { 
     $scope.toTrustedHTML = function (html) { 
      return $sce.trustAsHtml(html); 
     } 

     $scope.getLogin = function (proCode) { 
      alert("Code " + proCode); 
      $http({ 
       method: 'GET', 
       url: '/Home/getProviderLogin?id=' + proCode, 
      }). 
      success(function (data) { 
       debugger; 
       $scope.ProviderLogin = data; 
       $scope.ProviderLoginPop = true; 
       //$location.path = '~/WelcomePage.cshtml'; 
       $http.post("/Home/WelcomePage", { postId: id }); 
      }); 

     } 
    }); 

和下面是我的控制器代碼

public ActionResult getProviderLogin(string id) 
     { 
      var providercode = objHomeRepo.getLogin(id); 
      //return View("WelcomePage"); 
      return RedirectToAction("WelcomePage", "Home"); 

     } 

我想打電話給welcomepage看法,但它不是渲染....

+0

'$ http'是異步請求,所以你覺得'RedirectToAction '會工作嗎? – Satpal

+0

我是新角度請建議 –

+0

我試圖使用返回視圖(「WelcomePage」);同樣的問題 –

回答

1

重定向在ajax post中不起作用。您可以在控制器中返回目標網址,並在JavaScript代碼中手動重定向。

在你的控制器,回報您的網址

return Json(Url.Action("WelcomePage", "Home")); 

在JavaScript代碼中使用

$location.path('url') 

window.location.href = url; 
+0

謝謝你的工作...... –