Danny Sandi
Danny Sandi

Reputation: 707

Replace parent scope with directive attribute controller scope

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?

Upvotes: 0

Views: 50

Answers (1)

Andrei  Belokopytov
Andrei Belokopytov

Reputation: 1081

  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

Upvotes: 1

Related Questions