Yes, you have several options to do this.

You can :

1) Re-use the same directive function. Either by defining them in the same
file ( not a bad idea if they inherit ), or by using a factory that will
return/contain the function for sharing. You can then just extend the
directive object
just like a normal JS object. This is my favorite when it is available
because it is easiest and most straightforward.
2) Decorate the directive function in a provider. See:
http://stackoverflow.com/a/21956730
3) Re-use the directive's controller ( if that is all you need, could
easily be ) by using $controller.
4) .. or by using $compile require.
5) Finally, you can have the second directive add the first during link()
and then manually compile() ( and hook into scopes / isolate scopes if
necessary, but I would try to stay away from that ).




On Thu, Jul 2, 2015 at 10:25 AM, Erick Macedo <[email protected]>
wrote:

> Hi,
>
> You can use inheritance in directive in angularjs
>
> For example,
>
> Imagine we're using Angular Material containing elemente (directive)
> md-button, I would like to create another my-md-button and extend the
> directive ('mdButton').
>
> it's possible?
>
> thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to