Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Options could be data-bound #73

Closed
mbenford opened this issue Feb 11, 2014 · 5 comments
Closed

Options could be data-bound #73

mbenford opened this issue Feb 11, 2014 · 5 comments

Comments

@mbenford
Copy link
Owner

Currently all options are parsed and loaded only once when the directive is initialized. It may be useful (and more Angular-compliant) if they could be updated at any moment and their new values were used by the directive.

@simonbreak
Copy link

In particular, I need this feature for the placeholder. I want users to add exactly 3 tags so I want the placeholder to change, e.g. "Enter 3 tags", "Enter 2 more tags", "Enter 1 more tag" and then disappear. This should be pretty simple to do with a $watch inside the directive...

@adrianhara
Copy link

+1 for this

I guess declaring the options on the directive's isolated scope and then binding directly to them in the template would do the trick (in fact I've done this for the placeholder only to be able to update it at runtime).

As for supplying default values if the scope value is not there, maybe simply setting the default values once would be enough and a watch on each of them wouldn't be needed. This way someone not using option X gets the default behavior and also once/if he'd start using option X he'd have to manage it completely (including handling null/undefined values of it).

@mbenford
Copy link
Owner Author

Many if not most of the options aren't used within the templates so it isn't simply a matter of making them available for the view to use. That's why it isn't a good idea to declare the options on the directive's scope using @: they would all be strings and the code expects meaningful values (strings, integers, booleans, regular expressions etc); it would break at best and at worst it would just misbehave. That's also why default values should be enforced at any time: null and/or undefined values aren't expected by the code either.

Nevertheless, all infrastructure code is already in place to load, parse and validate attributes. It would be just a matter of extending that code to create an observer for every option.

@mbenford mbenford added this to the 2.0.0 milestone Feb 20, 2014
@adrianhara
Copy link

You're right, but what if they were declared using '=' instead of '@'? I think in this case they wouldn't be strings anymore.

@mbenford
Copy link
Owner Author

They wouldn't, but then all options would have to be placed within the scope so they could be bound to the directive's isolate scope. Not so nice. ;)

@mbenford mbenford modified the milestones: Post-2.0.0, 2.0.0 Mar 20, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants