0

I am having the worst time with the following code:

angular.
    module('albumCarousel').
    component('albumCarousel', {
        templateUrl: '/album-carousel/album-carousel.template.html',

        controller: function AlbumCarouselController($scope, $http) {
            /* the bane of my existence */
            console.log(this.category); // prints undefined..
        }
    }
)

In my html, I have the following:

<angular-carousel category="songs"></angular-carousel>

Going back to the component, in the controller,

this.category comes back as undefined.

How do I get it to return "songs"

KingFish
  • 8,773
  • 12
  • 53
  • 81

1 Answers1

0

After a bunch of googling, I found the answer: $onInit:

this.$onInit=function() {
    console.log(this.category)
}

I also had to add a binding:

    bindings: {
        category: '@',
    }

Thanks for all of your help

KingFish
  • 8,773
  • 12
  • 53
  • 81