如何在 AngularJS 在ajax回调里通过设置ng-s
1个回答
展开全部
<!-- 页面html片段-->
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-primary" ng-disabled="groupForm.$invalid" ng-click="saveGroup()">
保存<i class="fa fa-refresh fa-spin fa-lg fa-fw" ng-show="showLoading"></i>
</button>
</div>
//js controller代码
var teamModule = angular.module("TeamModule", []);
teamModule.controller('GroupCtrl', function($scope, $http, $state, $stateParams) {
$scope.showLoading = false;
$scope.groupInfo = {};
$scope.toggleLoading = function(isShow){
$scope.showLoading = isShow;
};
$scope.saveGroup = function(){
$scope.toggleLoading(true);
//请求使用jquery进行发送
$.ajax({
url: 'group/save',
data: $scope.groupInfo,
dataType: 'json',
type: "post",
success: function(data){
console.log(data);
$scope.toggleLoading(false);
},
error: function(){
$scope.toggleLoading(false);
}
});
};
});
<div class="col-sm-offset-2 col-sm-10">
<button class="btn btn-primary" ng-disabled="groupForm.$invalid" ng-click="saveGroup()">
保存<i class="fa fa-refresh fa-spin fa-lg fa-fw" ng-show="showLoading"></i>
</button>
</div>
//js controller代码
var teamModule = angular.module("TeamModule", []);
teamModule.controller('GroupCtrl', function($scope, $http, $state, $stateParams) {
$scope.showLoading = false;
$scope.groupInfo = {};
$scope.toggleLoading = function(isShow){
$scope.showLoading = isShow;
};
$scope.saveGroup = function(){
$scope.toggleLoading(true);
//请求使用jquery进行发送
$.ajax({
url: 'group/save',
data: $scope.groupInfo,
dataType: 'json',
type: "post",
success: function(data){
console.log(data);
$scope.toggleLoading(false);
},
error: function(){
$scope.toggleLoading(false);
}
});
};
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询