Skip to content

Instantly share code, notes, and snippets.

@machty
Created April 29, 2014 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machty/11391346 to your computer and use it in GitHub Desktop.
Save machty/11391346 to your computer and use it in GitHub Desktop.
Angular question about mixing in directive behaviors

Let's say I've declared three class-restricted directives "am-wat", "am-foo", and "am-bar", that each augment the attached element with some behavior, e.g.:

<div am-wat="some data" am-foo="other data" am-bar="lol">
  Yadda yadda yadda
</div>

Is there a way to write a directive that mixes in the behavior of the three directives, e.g.:

<div am-trifecta="trifecta args">
  Yadda yadda yadda
</div>

such that the trifecta directive invokes the behavior of each of the three directives on that div, passing each directive some args that the trifecta directive came up with? Can it be done in without requiring an intermediate DOM element being added, which might complicated or screw up existing styles?

@benlesh
Copy link

benlesh commented Apr 29, 2014

You're correct transpile was a typo.

The only reason you might have more flexibility with it element transpiled, is really just because it makes it more straight forward to replace the element with the other directives. Although I suppose you could still do that if they were attribute-based directives. I don't know... I was tired. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment