-
Notifications
You must be signed in to change notification settings - Fork 540
Options could be data-bound #73
Comments
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... |
+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). |
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 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. |
You're right, but what if they were declared using '=' instead of '@'? I think in this case they wouldn't be strings anymore. |
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. ;) |
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.
The text was updated successfully, but these errors were encountered: