-1

I am trying to bind to an angularjs 1.5 component a resolve value without success, In the state definition, I have replaced the common value of template properties with a value of the name of my new component. like this:

.state('eventslogs.create', {
        url: '/create',
        template: '<addevent data="$resolve.addevent"></addevent>.',
        resolve: {
          addevent: newEventslog
        },
        data: {
          roles: ['admin'],
          pageTitle: 'Eventslogs Create'
        }
      })

NewEventslog is a function that injects one of my services

newEventslog.$inject = ['EventslogsService'];

  function newEventslog(EventslogsService) {
    return new EventslogsService();
  }

In my controller I have tried several ways but nothing works

angular.module('eventslogs')
  .component('addevent', {
    templateUrl: 'addevent.client.component.view.html',
    bindings: {
      data: '<'
    },
    controller: function($scope, $element) {
      var vm = this;
      vm.eventslog = vm.data;
    }

But vm.eventslog always results in an undefined value, what's wrong with my aproach?, If I use "@" instead "<" in bindings, vm.addevent results in a string with value "$resource.addevent" and not like an instance of newEventslog function.

I am using ui-route version 0.2.18

1 Answer 1

2

not sure but try this inside the component

this.$onInit = () => {
  vm.eventslog = vm.data;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.