see the code and tell me where i made the mistake ?
- angular.module('myApp', [])
- .directive('loading', ['$http' ,function ($http)
- {
- return {
- restrict: 'A',
- template: '',
- 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;
- });
- }
- });
Rajkiran SwainPosted Jun 9, 2017, 8:29 AM
Loading spinner
"student in students"
>