1
我试图按照ng-show和ng-hide的工作方式。我希望在REST调用成功时显示表单,如果调用返回空值,则显示错误消息。AngularJS:ng-show usage
我还通过AngularJS: ng-show/ng-hide
,但还是不太明白他们究竟是如何工作去了。谁能帮忙?
我试图按照ng-show和ng-hide的工作方式。我希望在REST调用成功时显示表单,如果调用返回空值,则显示错误消息。AngularJS:ng-show usage
我还通过AngularJS: ng-show/ng-hide
,但还是不太明白他们究竟是如何工作去了。谁能帮忙?
使用承诺
var promise = service.Method();
promise.then(function(response) {
//Show
$scope.elementVisibility = true; $scope.errorMsg = false;
}, function(reason) {
// Hide
$scope.elementVisibility = false; $scope.errorMsg = true;
});
<form ng-show="elementVisibility"></form>
<div ng-hide="errorMsg"></div>
代码吗?一名运动员会更好。 –