Angular + ES6 Promise

It would be really nice if we could use native ECMAScript 2015 Promises with Angular instead of $q service that is provided from box to be close to pure JavaScript:

//somewhere inside component controller
let promise = new Promise((resolve) => setTimeout(() => resolve('resolved'), 2000));
promise.then(x => this.x = x);

But in this case we will have to run digest manually for each resolve(to synchronise view and model):

let promise = new Promise((resolve) => setTimeout(() => resolve('resolved'), 2000));
promise.then(x => {
  this.x = x;

But what if we hack the Promise and intercept our digest call there:

Continue reading

ui-router: Deprecated events and hooks

If you are using latest version of ui-router (now it’s 1.0.0-alpha) you probably already noticed that there are no events that we all got used to: $stateChangeCancel,  $stateChangeError, $stateChangeStart$stateChangeSuccess$stateNotFound. All of them are deprecated in 1.0.0-alpha.3 and you can not use them anymore in 1.0.0-alpha.5.

If you want to move to new version of ui-router you should make such changes:

Continue reading

ui-router: Default child for abstract state

In version 1.0.0alpha0 they finally make it possible! Child for abstract states? No! But now at least it’s possible to create own fix for it due to new $transitionsProvider, in which you could define onBefore hook. You can change the behaviour depends on state options. Let’s use “abstract” property that is boolean and extend it: to make it possible to add child state here:

        to: state => !!state.abstract
      }, ($transition$, $state) => {
        if (angular.isString($ {
          return $$;

basically if abstract param is a string we set it like a target. Example of use:

          name: 'abstract2',
          url: '/abstract2',
          abstract: '', // redirect to ''
          template: 'abstract2'

Continue reading

Idea: Grunt/gulp/webpack config builder


I don’t know why such kind of service still have not been invented. It’s not only about grunt/gulp or webpack but also about build tools of such kind.

It could be so useful: you just feed your github repo to the service and in step by step wizard create your config file. After all you have pull request with changes(new config file) to your project.