Hi all,
New to the group and also to the AngularJS, so I hope the questions is not
duplicate (tried to search both forum and google). So I was looking if
angular JS could be an easy switch for my company project or could be used
as platform for other projects here. Having been working on frameworks in
the same landscape I really for now like the generalizations that Angular
does over UI development experience through years and nicely throws them
into the web framework. A lot of the concepts are inlined with what I need
and with our current code base (and actually quite some stuff fills in the
blanks we need). So far so good, but when it comes to templates I'm a bit
confused by the choices made... And my main question here would be why were
the attribute-style dirrectives chosen over element-style dirrectives?
We have a home grown templating that mostly matches Angular concepts and I
think could be easily either translated into or implemented in Angular
terms, but it intensively uses element directives. And I must say I do
prefer this style for couple of reasons:
* I think it scales easier - you define element directive which defines
the primary goal of directive and then you can add as many paramters as you
want using attributes, while for attribute directive I need to either
invent syntax or declare some namespaced attributes on element it was
applied to (a subject to possible clashes).
* It is no subject for clashing - I think it's very easy to screw up and
harder to design chainable dirrectives, while they would be quite
prolifterated by attribute syntax. On the other side elements eliminate
that design choice from you (which is I think benefitial for a lot of
dirrectives).
* Element dirrective can hold both DocumentFragment and Node content,
while attribute dirrectives only apply to Node, hence the
ugly ng-repeat-start and ng-repeat-end, which also complicates the
processing of the template for analysis purpose (instead of just
//ng:repeat I would need a very complex selector).
* the added semantics of element is more clear than the added semantics
of attribute - the latter tries to modify semantics of already existing
object in a strange way (you add semantic to li that it can be repeated -
isn't this weird semantic?).
I tried to evaluate the downsides:
* Maybe harder to pass validator (is it? cause I'm really not hardcore
user of HTML validation but I would hope that unrecognized elements are
less critical error than unsupported attribute, hence always need for
"data-"), which is really not a concern for me (I prefer XML validation).
* Maybe harder to hide directives from initial view, but I don't think
current attribute syntax is much better in that regard as you can still
have {{expr}} in your text node (hence visible intially), to make it really
clean of visualization you would really need to follow the Thymeleaf
template syntax conventions (which I disslike pretty much).
I can of course miss a lot of points here, but to summarize:
* What is the reasoning behind the choice?
* Is there an alternative/lib/work in progress to have element based
syntax for most directives that work with composition (ngRepeat, ngInclude,
etc.)?
* Is this something that will not be available in package with current
vision?
Thanx in advance,
Bohdan
--
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/groups/opt_out.