Skip to main content

Make page reload in angular if the dom is having problem with jquery javascript ot require js anything in dom is not working.


Make page reload in angular if the dom is having problem with jquery javascript ot require js anything in dom is not working.

myApp.controller('mainController', ['$scope', '$rootScope', '$location', '$log', '$route', '$cookieStore', '$interval', function($scope,$rootScope,$location,$log,$route,$cookieStore,$interval){
      $rootScope.hideit = false;
       
      var startTime = new Date();
      var firstR = new Date($cookieStore.get('firstreload'));
      var diff = startTime - firstR;
      var finalDiffToCheck = diff/1000;

      if($cookieStore.get('firstreload') === undefined){
        $log.info("case page has not been loaded at all");
      }

      if(finalDiffToCheck > 4){
        $log.info("case page has to be reloaded");
        window.location.reload();
      }
     
      //$log.info("first reload : "+$cookieStore.get('firstreload'));
      //$scope.stopwatch = startTime.getSeconds();
      $cookieStore.put('firstreload',startTime);
      $log.info("Start time : "+startTime);
      $log.info(finalDiffToCheck);
      /*
      $interval(function() {
          $scope.stopwatch = (new Date() - startTime) / 1000;
      }, 1000);
      */
     

      //$log.info($rootScope.lname);
      $scope.cdate = new Date();

      //$route.reload();
      //$rootScope.lname
      //$cookieStore.put('tabc',"abcedf");
      //$log.info($scope.cdate);
      //$log.info($cookieStore.get('tabc'));
      //$log.info($location.path());
      var loadedornot = $rootScope.lname;
      if(loadedornot === undefined){
       // $location.path('/loaded');
       $rootScope.lname = 'navin';
       //$log.info("i am not defined");
       // $log.info($rootScope.lname);
      }
     
      //$scope.load();
}]);

Comments

Popular posts from this blog

Error: ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' solution this solved the issue sudo npm install -g ios-deploy -unsafe-perm

Error: ios-deploy was not found. Please download, build and install version 1.9.0 or greater from https://github.com/phonegap/ios-deploy into your path, or do 'npm install -g ios-deploy' solution this solved the issue sudo npm install -g ios-deploy -unsafe-perm

How to upload file in MEAN Stack

How to upload file in MEAN Stack Do these steps 1. npm install ng-file-upload 2. include ng-file-upload.min.js in your angular index .html 3. Use this example to copy form to your angular page from where u want to upload file. -- http://jsfiddle.net/0m29o9k7/ or http://jsfiddle.net/danialfarid/2vq88rfs/136/ Copy this code outside of any form which is already there: 4. Change this url from example code to where you want to upload files -- url: 'https://angular-file-upload-cors-srv.appspot.com/upload', 6. In your server.js or app.js which ever you are using as (node server.js) to start app add these lines     var crypto = require('crypto');         var mime = require('mime');         var multer  = require('multer');                     var storage = multer.diskStorage({           destination: function (req, file, cb) {     ...