我剛剛開始使用Angular js。我對此表示懷疑。我想在重定向之後設置flash消息。在angularjs中重定向後設置flash消息
在我的情況下,我有一個表單,並通過http requst保存數據。在成功函數中,我把window.location()。這是另一頁。我想在該頁面中設置一條Flash消息。
JS
$scope.Save_Details = function (id)
{
$http.post(base_url+"sur/sur/save_data/"+id,{data:$scope.Surdata}).
success(function(response) {
// $scope.successTextAlert = "Saved";
// $scope.showSuccessAlert = true;
window.location = "#/surpage/nextpage?show_message= true";
});
}
新的更新
var messageFlag = $location.search().show_message;
if(messageFlag && messageFlag === 'true'){
alert(messageFlag);
$scope.successTextAlert = "Saved";
$scope.showSuccessAlertMsg = true;
}
視圖
<div class="alert alert-success" ng-show="showSuccessAlert">
<button type="button" class="close" data-ng-click="switchBool('showSuccessAlert')">×</button> <strong> {{successTextAlert}}</strong>
</div>
誰能幫助我?
將查詢字符串/路由數據標誌傳遞給另一個頁面,讀取標誌並相應地顯示flash消息 – Developer
我不清楚這一點。可以解釋..? – user6721756
1.當您導航到「nextpage」時,沿着 - >#/ surpage/nextpage?show_message = true 2傳遞一個標誌。在「nextpage」控制器中,讀取「show_message」($ location.search()。show_message)的查詢字符串值,如果該值== true,則顯示您的flash消息 – Developer