Html 在Angular JS中单击一次即可显示消息并刷新页面
我想在显示消息或警报并说“成功”后刷新页面,反之亦然。我如何实现它 我尝试重新设计代码,但之后它不会显示消息Html 在Angular JS中单击一次即可显示消息并刷新页面,html,angularjs,Html,Angularjs,我想在显示消息或警报并说“成功”后刷新页面,反之亦然。我如何实现它 我尝试重新设计代码,但之后它不会显示消息 HTML CODE: <div class="row" ng-controller="PublishManifestCtrl"> <div class="col-xs-12 col-md-12"> <div class="widget"> <div class="widget-header bordered-bottom
HTML CODE:
<div class="row" ng-controller="PublishManifestCtrl">
<div class="col-xs-12 col-md-12">
<div class="widget">
<div class="widget-header bordered-bottom bordered-themeprimary">
<i class="widget-icon fa fa-tasks themeprimary"></i>
<span class="widget-caption themeprimary">Manifest Status</span>
</div>
<div class="widget-body">
<form class="form-bordered" role="form">
<div class="form-group">
<label style="padding-left: 8px;">Manifest was last published to agents on <b>{{manifeststatus.manifestLastPublishedDate}}</b>.</label>
</div>
<div class="form-group">
<label style="padding-left: 8px;">Manifest was last updated by <b> {{manifeststatus.lastUpdatedByUser}} </b> on <b>{{manifeststatus.manifestLastedUpdatedDate}}</b>.</label>
</div>
<div class="form-group">
<div class="col-sm-offset-1">
<button id="PublishButton" class="btn btn-default shiny " ng-disabled="manifeststatus.enablePublishButton" ng-click="Save(manifeststatus)">Publish</button>
</div>
<br/>
<div id="statusDivPublish" ng-show="showstatus">
<alert type="{{alert.type}}">{{alert.msg}}</alert>
</div>
</div>
</form>
</div>
实施
$scope.Save = function (data) {
// debugger;
$http.post($rootScope.WebApiURL + '/updatemanifeststatus');
//made change
$scope.manifeststatus = data;
$scope.showstatus = true;
$scope.alert = { type: 'success', msg: 'Published Successfully.' };
$(".statusDivPublish").show();
//refresh
$state.transitionTo($state.current, $stateParams, {
reload: true,
inherit: false,
notify: true
});
}
});
本来应该是这样的:
在html中
<div>{{date}}</div>
但是为什么要重新加载页面呢?angular使用双向数据绑定,如果您想在服务响应后更改任何内容,只需更改$scope@maddygoround因为,在该按钮上,单击“我正在将当前系统日期/时间上载到DB,并希望将其返回到屏幕上。将该日期/时间分配给任何范围变量..当您分配一个值时,它将自动反映到html@maddygoround我对帖子做了修改。即将添加Html代码too@maddygoround您的意思是说我应该添加$scope.manifeststatus=data;还是在save()函数中?
<div>{{date}}</div>
$scope.Save = function (data) {
$http.post($rootScope.WebApiURL + '/updatemanifeststatus');
$scope.date = data.date;
//refresh
$scope.showstatus = true;
$scope.alert = { type: 'success', msg: 'Published Successfully.' };
$(".statusDivPublish").show();
$(".statusDivPublish").remove();
)});