1

I am trying to write custom directive. This is a fork from an example by Andy Joslin.

Please see the code http://plnkr.co/edit/jXfr6P?p=preview

I could pass the selection method to the first child scope, but not further. I know ng-repeat create child scopes, and the original example updates the model correctly. But, not sure how to call the function.

Click on Apparel -> sel = Apparel ==> works
Click on Mens Shirts  -> sel = Apparel ==> Not OK (needs to be Mens Shirts )
Click on Mens Special Shirts -> sel = Apparel ==> works Not OK (needs to be Mens Special Shirts)
...
Click on Boats -> sel = Boats ==> works

1 Answer 1

3

I've managed to fix your example. The key to finding the solution was to change the directive scope to:

 scope: {
      tree: '=ngModel',
      selection:'=selection' // changed & to =
    }

as you have to pass the selection function for each tree and choice this way:

selection="selection" // was selection="selection(val)"

See my forked plunker: http://plnkr.co/edit/2tal6V?p=preview

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.