Skip to content

Instantly share code, notes, and snippets.

@hmbilal
hmbilal / README.md
Last active June 18, 2019 15:05
Long polling service in AngularJS

Then in your controller, inject $polling and start polling like this.

General use

$polling.startPolling({name_of_this_polling}, {url_to_fetch_data_from}, {time_in_milli_seconds}, {callback});

Example,

$polling.startPolling('fetchNotifications', 'http://localserver.local/fetch/notifications', 10000, $scope.processData);

@hmbilal
hmbilal / IndexController.php
Last active May 23, 2018 10:17
Uploading multiple files in Zend Framework 2 (solution for file is uploaded illegally in zf2)
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController,
Lists\Entity\Lists;
class IndexController extends AbstractActionController
{
public function indexAction()
{
@hmbilal
hmbilal / debug-ui-router.js
Last active October 23, 2024 09:05
Debugging Angular ui-router routes in browser console.
// Paste this code in browser console to debug ui-router problems when navigating through states.
var $rootScope = angular.element(document.querySelectorAll("[ui-view]")[0]).injector().get('$rootScope');
$rootScope.$on('$stateChangeStart',function(event, toState, toParams, fromState, fromParams){
console.log('$stateChangeStart from '+fromState.name+'- fired when the transition begins. fromState,fromParams : \n',fromState, fromParams);
console.log('$stateChangeStart to '+toState.name+'- fired when the transition begins. toState,toParams : \n',toState, toParams);
});
$rootScope.$on('$stateChangeError',function(event, toState, toParams, fromState, fromParams){