Directive to Directive Communication in AngularJS

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

In Angular JS, you can use one directive as an element and other directives as attributes to the element, allowing you to specify different functionality for elements based on the attributes in the element. This lesson shows you how to take a group of directive elements and give them each unique functionality based on their directive attributes.

Harrison
~ 10 years ago

Hi, why does $scope.abilities not save the values pushed into it when mouseenter? Such that having mouseenter into 'The Flash' does not produce ['flight', 'flight', 'flight']?

Dominik
~ 9 years ago

In video You expose controller from directive "superhero", but in JS BIn code it is exposed as "normal" controller ? I need to expose controller from directive , but got error " Controller 'xxx', required by directive 'yyy', can't be found!". What is ok and what is wrong ?

Dominik
~ 9 years ago

using require: "^controllerFromDirective" helped ( ^ which means "search above" ??? )

Jason
~ 9 years ago

It doesn't do that because the elements are not pushed to the array on mousenter, they're pushed on the creation of the element.

If there was something like this it would be a different story:

$element.bind("mouseenter", function() { superman.addSpeed(); console.log(superman.abilities); });

George
~ 9 years ago

Sorry for off-topic question, but how do you do that magic with quick text search and navigation between occurrences? Some kind plugin for WebStorm? Thanks

Joel Hooks
~ 9 years ago

cmd-shift-a will basically let you search for any action in WebStorm and cmd-e is a "recent files" dialog. I like to use both!

I didn't watch the lesson recently, but those are the two I use that might be what you're asking 😜