Wednesday, 15 September 2010

angularjs - Advantages of using `ng-include src` -



angularjs - Advantages of using `ng-include src` -

i working on application contains number of html , js files.

in 2 different html files, 1 div construction (which uses ng-repeat) going same. controller render div construction going same.

style of div construction going different on both html pages.

now question , should create different html file have div construction in , utilize ng-class give different style structure. generic html included using ng-include src.

or should copy-paste same div construction in 2 different html files? sense advantage of doing don't have maintain number of flags , utilize complex ng-class structure.

so sum up, advantages of including 1 html file using ng-include src on copying div construction in 2 different html files.

the advantage of ng-include on re-create , paste here, said, of maintenance. when comes time alter html content reason, not have create changes in 2 (or more) places; one. so, if html fragments identical , alter together application grows, utilize ng-include.

to style 2 fragments differently: yes, can ng-class attach different css classes based on basic logic. "complete ng-class structure" mentioned, maybe there way simplify that. show more code , can help create simpler.

and if @ point of time in future, styles , of other attributes of deviates, don't hesitate fork template and/or controller. maintainability of each solution discussed in illustration dependent on how much commonality exists, can alter on time.

angularjs angularjs-ng-include

No comments:

Post a Comment