0

I've had no success creating an Attribute directive that uses vm in the child elements and uses the directive controller scope and no it's parent scope.

See: http://fiddle.jshell.net/vzuf9psq/

How can I make the second message show the message from the directive controller?

1 Answer 1

1
  1. Use directive scope to transfer properties from one controller to another
  2. Use bindToController to bind directive scope to controller (or much better, use Angular component's syntax).
  3. Do not paste template inside directive tag (or use transclude for this purpose)

See Final fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah using a template seems to fix the issue, I guess that if the directive adds no markup and there's no data binded (sometimes is not needed) the scope will never exist outside the controller. Thanks!

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.