Hacker News new | ask | show | jobs
by illicium 4312 days ago
Not every directive attribute needs to be another directive -- it's probably overkill, especially if the attribute applies to only on one type of element. ngValue is an example of dogfooding directives with more directives.

UI Router states are pretty tightly bound to the URL fragment path, which makes it difficult to point to all the parallel states that make up that particular view "configuration"

Say you have a page /foo that shows two sets of tabs, A B and X Y. To point to foo with tabs A and X open, you need put that in the URL, e.g. /foo/A,X, or express it as a state path foo.A,X. It gets even hairier if you then want to activate children of those states, e.g. A.a and X.x.

You could implement your own subview routing with ngSwitch and stateParams (perhaps query parameters). It's obviously not a great solution.

1 comments

> Not every directive attribute needs to be another directive -- it's probably overkill,

I think that this particular example shows that rather than extending framework of directives to nicely incorporate lightweight directives such as ng-required angular team chose to hack it into input/select/textarea directive because it was easier that way for them. There are many places like that in angular where the hacky path was chosen and due to this, architecture is lacking some of very obvious features like one-way binding of expression given in attribute to isolate scope (which is what ng-requried does to get it's value). You need to use & as workaround to achieve one way binding.

As for Angular UI as I said there were people that wanted to figure out how to implement tabbed views but they got no love from core developers. Basically recent advice about using UI Router to implement tabbed app is "Don't".

So I just went to implement my own stuff with $route, $routeParams, $location and ng-include.