Search code examples
angularjsangularjs-directiveangularjs-components

Plug angularjs directive into component


I currently have a generic list component and I want to add, depending on where I use it, different callbacks for adding/removing/updating items to that list.

My current implementation looks like this:

<div list-callback1>
    <generic-list
        add-callback="listCallback1.add()"
        update-callback="listCallback1.add(id, name)"
        delete-callback="listCallback1.delete(id)"></generic-list>
</div>

My question:

Is there a way to decrease nesting? Because when I add the directive directly to my component I get a compile error.


Solution

  • Ok, it was a different problem.

    I had scope: true in my list-callback1 directive.

    After removing that, all works fine. Thanks for the help

    Sorry I couldn't post more code, but I am restricted by my employer ;)