Skip to content
This repository has been archived by the owner on May 5, 2018. It is now read-only.

Directive Aliases #382

Closed
ProLoser opened this issue Jan 25, 2013 · 7 comments
Closed

Directive Aliases #382

ProLoser opened this issue Jan 25, 2013 · 7 comments
Labels
Milestone

Comments

@ProLoser
Copy link
Member

This is an idea for a new feature.

Lets say that EVERYONE prefixes their libs properly instead of imposing a global DSL:

  • bs-tooltip
  • bs-tabs
  • ui-reset
  • ph-txt

Now, lets say that I want to create a DSL but I don't want to re-define all these directives.

What if you could alias and stack these directives together? (say upon module.config or adding a third-party lib as a dependency)

<tabs title="Hello"> would essentially be the same as <li bs-tooltip bs-tabs ui-reset ph-txt title="Hello">

This way, people won't have to wonder if they should use the global namespace when making their library (like we do for angular/ui-bootstrap)!

In addition, you could create an alias for various configurations of the same directives!

@sudhakar
Copy link

👍 for the idea, but i am curious, about the implementation part.
When directives are aliased,

  1. What should be the priority of the aliased directive?
  2. Is it allowed to overshadow existing directive like input or ui-if
  3. Are we going to make it templatable, something like <text-input> expandable to full glory of BS markup
  4. If we are going to alias, lets say ui-reset& xy-field, both having a common attribute on-close, what happens then?

@ProLoser
Copy link
Member Author

  1. It actually doesn't need to deal with petty things like 'priority' because directives already tackle priority for us :) lol.
  2. "overshadow"? What do you mean? Anything you define inline will be transcluded (classes, properties, more directives, contents, etc)
  3. Actually, this sort of steps on the toes of our ui-input idea which is specifically for what you describe. In fact, maybe I should just go back to the drawing board and look at it again lol.
  4. You're dumb. Don't do that. The same thing happens that would happen if someone tried to do it in the expanded form, it's not our problem.

In all seriousness, this was thought up in an attempt to tell developers that they should namespace EVERYTHING so that it won't be a big deal if you want to use a streamlined syntax instead (like AngularUI vs UIBootstrap). See #191 for a similar thread.

@sudhakar
Copy link

Ohh, I should have explained little better. By priority, i ment the priority of the directive. Let's say someone creates an alias as form, then should it be allowed to overshadow the default form directive or should an error be thrown?

I guess, it should be fine to override, if there is a name conflict.

For 4, I ment allowing the user to specify the attrs as params in the config object. Then all that we need to do is $interpolate the template with the params object and then rest is all magic.

@petebacondarwin
Copy link
Member

Right now, if there are two directives with the same name they will both be
run by the compiler, in the order defined by their priority. So you can
already add a new "form" directive if you want that will run alongside the
core ng directive.

On 26 January 2013 01:37, sudhakar [email protected] wrote:

Ohh, I should have explained little better. By priority, i ment the
priority of the directive. Let's say someone creates an alias as form,
then should it be allowed to overshadow the default form directive or
should an error be thrown?

I guess, it should be fine to override, if there is a name conflict.

For 4, I ment allowing the user to specify the attrs as params in the
config object. Then all that we need to do is $interpolate the template
with the params object and then rest is all magic.


Reply to this email directly or view it on GitHubhttps://github.com//issues/382#issuecomment-12728865.

@ProLoser
Copy link
Member Author

Ah so I was right. Directives DO stack up.

Dean Sofer
DeanSofer.com
714.900.2254

On Saturday, January 26, 2013 at 1:54 AM, Pete Bacon Darwin wrote:

Right now, if there are two directives with the same name they will both be
run by the compiler, in the order defined by their priority. So you can
already add a new "form" directive if you want that will run alongside the
core ng directive.

On 26 January 2013 01:37, sudhakar <[email protected] (mailto:[email protected])> wrote:

Ohh, I should have explained little better. By priority, i ment the
priority of the directive. Let's say someone creates an alias as form,
then should it be allowed to overshadow the default form directive or
should an error be thrown?

I guess, it should be fine to override, if there is a name conflict.

For 4, I ment allowing the user to specify the attrs as params in the
config object. Then all that we need to do is $interpolate the template
with the params object and then rest is all magic.


Reply to this email directly or view it on GitHubhttps://github.com//issues/382#issuecomment-12728865.


Reply to this email directly or view it on GitHub (#382 (comment)).

@ProLoser
Copy link
Member Author

I decided to push a prototype: https://github.com/angular-ui/ui-alias

@bhantol
Copy link

bhantol commented Mar 23, 2016

That prototype does not work. Seems only limited to templates

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants