TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tri_inn
NA
1.2k
235.5k
AngularJS Showing Busy icon when loading data
Jun 9 2017 8:03 AM
i have created a small example which would show spinner when data will be loading. create directive for this because i can reuse it. problem is spinner loading all the time which is not right.
see the code and tell me where i made the mistake ?
angular.module(
'myApp'
, [])
.directive(
'loading'
, [
'$http'
,function ($http)
{
return
{
restrict:
'A'
,
template:
'<div class="loading-spiner"><img src="http://www.nasa.gov/multimedia/videogallery/ajax-loader.gif" /> </div>'
,
link: function (scope, elm, attrs)
{
scope.isLoading = function () {
return
$http.pendingRequests.length > 0;
};
scope.$watch(scope.isLoading, function (v)
{
if
(v){
elm.show();
}
else
{
elm.hide();
}
});
}
};
}])
.controller(
'myController'
, function($scope, $http) {
$scope.loadData = function() {
$scope.students = [];
$http.
get
(
'https://api.myjson.com/bins/x1rqt.json'
)
.success(function(data) {
$scope.students = data[0].students;
});
}
});
jsfiddle link https://jsfiddle.net/tridip/6L6p0bgd/
Reply
Answers (
2
)
Regarding Date picker in Angular 2
Angular 1.x or Angular 2.0