我刚刚开始使用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