Use resolve with angularjs component Use resolve with angularjs component angularjs angularjs

Use resolve with angularjs component


Your code is missing attribute and binding in order for resolve to work.

angular.module('app')     ...       template: '<customers test="$resolve.test"></customers>',                  resolve: { test: function () { return {value: 'nihao'}; } },     ...     });(function myCustomersConfig() {   function MyCustomersComponent {      // You can use test right away, and also view as $ctrl.test      console.log(this.test);   }  angular.module('app')    .component('myCustomers', {       templateUrl: 'app/customers/customers.html',       controller: MyCustomersComponent,       bindings: {          test: "<",       }         });}());


Add bindings to your component and remove it from your controller function

angular.module('app').component('myCustomers', {    templateUrl: 'app/customers/customers.html',    controller: MyCustomersComponent,    bindings: {        'test': '<' // or @ for string    }});class MyCustomersComponent {    constructor() {      // this.test should already exist      console.log(this.test);    }    ....