Angular.js: Angular 1.6 broke ui-router component resolves

Created on 24 Dec 2016  路  4Comments  路  Source: angular/angular.js

Do you want to request a feature or report a bug?
I guess it's a bug

What is the current behavior?
On Angular 1.5.8 my project was working normally.
I use resolvers on ui-router (1.0.0-beta.3) with components like this:

.state('companies', {
      url: '/companies',
      component: 'companiesPage',
      resolve: {
           companies ($q) {
                 "ngInject";
                 ... some code to build the array of promises;
                 return $q.all( array of promises); 
           }
      }
})

And my companiesPage component follows:

let companiesPageComponent = {
  bindings: {
    companies: '<',
  },
  template,
  controller
};

On Angular 1.5.8 I could access the companies variable inside my controller with this.companies which is an array as a result of my component resolve.
When updating to Angular 1.6.1 this.companies is undefined.

Any thoughts?

I'm sticking with Angular 1.5.8 for now as I have to deliver this project ASAP.

What is the expected behavior?

ui-router resolves should work with component bindings and you should be able to access them on controller.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

Angular 1.6.1

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Not really. It's just returning undefined from my route resolve function.

Most helpful comment

@vjoao Using $onInit guarantees that the bindings are assigned before using them

All 4 comments

Just tested, It's working on 1.5.10 as well.

@vjoao Using $onInit guarantees that the bindings are assigned before using them

_"If you don't have time to migrate the code at the moment, you can flip the
setting back to true:"
Thanks, Angular... I don't. HAHA

I just missed that. Thanks anyway guys.

Was this page helpful?
0 / 5 - 0 ratings