[英]AngularJs how to switch from one view to another from a controller
我是angularJs的新程序員。 我正在實現一個簡單的CRUD應用程序,以顯示客戶端列表。 從客戶端列表中,我有一個“添加客戶端”按鈕,可移動到AddClient視圖。 從addClientView單擊保存按鈕后,我想發送請求以保存客戶端,然后返回客戶端列表
這是我的app.js中處理客戶端保存的函數:
$scope.addClient = function(isValid) {
if (!isValid) {
$scope.displayValidationError = true;
return;
}
var url = "/myApp/clients/add";
var config = {
headers : {
'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
}
};
$http.post(url, $.param($scope.client), config).success(
function(data) {
var urlWhereToBack = "/myApp/clients/list";
//here code to launch this url and switch to the list of client
........
........
}).error(function(data, status, headers, config) {
$scope.handleRequestError(status);
});
};
因此,保存客戶端后,我要啟動網址“ / myApp / clients / list”以返回到客戶端列表
我該怎么辦?
您不想通過Angular中的URL在“視圖”中導航。
看一下ui-router並使用$ stateS。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.