0
我只是想知道是否有人可以帮助我。我正在写角度的应用程序,我堆栈。我在服务器端使用php和MySQL,并且所有的工作都很好。所有的http请求都在服务中。有时当请求大量数据或响应需要一段时间时,由于某种原因前端存在延迟。我已经有使用svg在css中加载动画。我不知道如何实现它我的应用程序。当数据从服务器传入时,显示装载程序的效果会更好。角度加载动画
我不是要求现成的解决方案,但对于在我的应用程序中实现它的最佳实践有一些建议。
以下是我的登录服务示例。
'use strict';
app.factory('loginService', function($http, $location, sessionService) {
\t // Service must return
\t return {
\t \t login: function(user, scope) {
\t \t \t // Send credential to the server
\t \t \t var $promise = $http.post('http://localhost:8888/myApi/api/login/user.php', user);
\t \t \t $promise.then(function(msg) {
\t \t \t \t var uid = msg.data;
\t \t \t \t if(uid) {
\t \t \t \t \t if(uid.status == 'success') {
\t \t \t \t \t \t //scope.msgtxt = uid.response.success;
\t \t \t \t \t \t sessionService.set('uid', uid.session);
\t \t \t \t \t \t $location.path('/home'); \t \t \t \t \t \t
\t \t \t \t \t } else {
\t \t \t \t \t \t scope.msgtxt = uid.error;
\t \t \t \t \t }
\t \t \t \t } else {
\t \t \t \t \t $location.path('/login');
\t \t \t \t }
\t \t \t })
\t \t },
\t \t logout: function() {
\t \t \t sessionService.destroy('uid');
\t \t \t $location.path('/login');
\t \t },
\t \t islogged: function() {
\t \t \t var $checkSessionServer = $http.post('http://localhost:8888/myApi/api/login/check_session.php');
\t \t \t return $checkSessionServer;
\t \t }
\t }
});
你不知道我有多感激,我只是测试它的魅力,这是太棒了。正是我在找什么。非常感谢! – CyberFountain
+ Wolfy很高兴听到我的帮助。 –