0

I am trying to load Image icon(set time to load particular for 30 Second) while loading the data from the database but I am facing some problem as I want to set timer also for Loading Icon (i.e Loading Icon appear for 30 second) using angularjs. How I achieve this functionality as I was done this by ng-show and ng-hide but I am unable to attach time in Icon. my Code is

     editApp.controller('MyCtrl', ['$scope', '$http', 'ngDialog','$timeout' ,function ($scope,$http, ngDialog, $timeout) {
             GetList();
             $scope.dataloaded = false;

and after ajax call I set $scope.dataloaded to true

    function GetList() {
                 debugger;

                 $http({
                     method: 'GET',
                     url: '/Home/GetProductList'
                 }).
                 success(function (data) {

                     if (data != null || data != 'undefined') {
                         $scope.productlist = data;
                         $scope.dataloaded = true;
                     }
                 })
                 .error(function (error) {
                     $scope.status = 'Unable to retrieve product' + error.message;
                 });


             }

and my html code is

<div ng-hide="dataloaded" style="margin:auto" align="center"> </div>

and

<div ng-show="dataloaded" style="margin:auto" align="center"> </div>

1 Answer 1

1

Lets show div for 30 sec:

<button ng-click='show()'>Show</button>
<div ng-show='showDiv'/>

In controller:

$scope.show = function() {
    $scope.showDiv = true;
    $timeout(function() {
        $scope.showDiv = false;
    }, 30000);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.