角度加载动画(Angular loading animation)

编程入门 行业动态 更新时间:2024-10-10 15:23:17
角度加载动画(Angular loading animation)

我只是想知道是否有人可以帮助我。 我正在写角度应用程序和我堆栈。 我在服务器端使用php和MySQL,一切都很棒。 所有http请求都在服务中。 有时,当请求大量数据或响应需要一段时间时,原因是前端有延迟。 我已经使用svg在css中设计了加载动画。 我不知道如何实现它我的应用程序。 当数据从服务器传入时,理想的效果是显示加载器。

我不是要求现成的解决方案,而是要求在我的应用程序中实现它的最佳实践的一些建议。

以下是我的登录服务示例。

'use strict';

app.factory('loginService', function($http, $location, sessionService) {
	// Service must return
	return {
		login: function(user, scope) {
			// Send credential to the server
			var $promise = $http.post('http://localhost:8888/myApi/api/login/user.php', user);
			$promise.then(function(msg) {
				var uid = msg.data;
				if(uid) {
					if(uid.status == 'success') {
						//scope.msgtxt = uid.response.success;
						sessionService.set('uid', uid.session);
						$location.path('/home');						
					} else {
						scope.msgtxt = uid.error;
					}
				} else {
					$location.path('/login');
				}
			})
		},
		logout: function() {
			sessionService.destroy('uid');
			$location.path('/login');
		},
		islogged: function() {
			var $checkSessionServer = $http.post('http://localhost:8888/myApi/api/login/check_session.php');
			return $checkSessionServer;
		}
	}
}); 
  
 

I just wondering if anyone could help me. I am writing angular app and I stack. I'm using php and MySQL on the server side and all works great. All the http requests are in the services. Sometimes when large amount of data is requested or response is taking a while for what ever reason there is a delay on the front end. I already have loading animation designed in css with use of svg. I have no clue how to implement it it my app. Desirable effect would be to display loader when data is incoming from the server.

I am not asking for ready solution but for some advice on what is the best practice to implement it within my app.

Below is example of my login service.

'use strict';

app.factory('loginService', function($http, $location, sessionService) {
	// Service must return
	return {
		login: function(user, scope) {
			// Send credential to the server
			var $promise = $http.post('http://localhost:8888/myApi/api/login/user.php', user);
			$promise.then(function(msg) {
				var uid = msg.data;
				if(uid) {
					if(uid.status == 'success') {
						//scope.msgtxt = uid.response.success;
						sessionService.set('uid', uid.session);
						$location.path('/home');						
					} else {
						scope.msgtxt = uid.error;
					}
				} else {
					$location.path('/login');
				}
			})
		},
		logout: function() {
			sessionService.destroy('uid');
			$location.path('/login');
		},
		islogged: function() {
			var $checkSessionServer = $http.post('http://localhost:8888/myApi/api/login/check_session.php');
			return $checkSessionServer;
		}
	}
}); 
  
 

更多推荐

app,function,server,电脑培训,计算机培训,IT培训"/> <meta name="descripti

本文发布于:2023-07-17 14:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1145673.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   角度   动画   animation   loading

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!