admin管理员组文章数量:1421031
I've been looking at frameworks to help me write better structured JS code and came across Backbone. It seems to have lots of functionality for creating classes with public and private properties and members, inheritance, etc.
Angular JS seems to do a load of pletely different stuff like automatic binding of markup to model and lots of clever trickery for templating, filtering, sorting etc.
My question is not which should I choose, but is it sensible to use both? AngularJS looks really cool, but unless I'm missing something then it doesn't seem to provide any OO stuff for you to work with. Does this make sense?
I've been looking at frameworks to help me write better structured JS code and came across Backbone. It seems to have lots of functionality for creating classes with public and private properties and members, inheritance, etc.
Angular JS seems to do a load of pletely different stuff like automatic binding of markup to model and lots of clever trickery for templating, filtering, sorting etc.
My question is not which should I choose, but is it sensible to use both? AngularJS looks really cool, but unless I'm missing something then it doesn't seem to provide any OO stuff for you to work with. Does this make sense?
Share Improve this question asked Aug 6, 2012 at 9:57 jonhobbsjonhobbs 28k39 gold badges118 silver badges179 bronze badges 1- 1 I find my self in the same dilema, I think this is a very respetable question. Angular provider a lot of magic for binding stuff but I'm missing some kind of inheritance and collections abstraction as Backbone provides. – fguillen Commented Mar 28, 2014 at 10:33
3 Answers
Reset to default 3I'm not sure that pairing Angular with another framework would really make a lot of sense, it's quite plete as it is.
Backbone on the other hand is more posable, for instance you might take a look at the Knockback project, which make Backbone and KnockoutJS work together quite nicely. Knockout takes a MVVM approach which is relatively close to what you'll find in Angular.
If you need to write OO for your data (aka Models), just use a library like Base.js. It gives you nice OO syntax, inheritance, with methods like extend
. The good part is that it keeps the getter syntax like myObject.var
so it plays nicely with Angular, contrarily to Backbone where you need to use a getter myObject.get('var')
, so data bindings works just fine.
To understand the difference and the reason between those syntaxes and philosophy, read one of the Angular author's answer here in SO.
AngularJS purposely does not impose any particular inheritance style, so you're free to do whatever you want. If you like Backbone.js's inheritance model, you can use underscore (which is included in Backbone.js) to provide the .extend
helper.
本文标签: javascriptUsing AngularJS with BackboneJSStack Overflow
版权声明:本文标题:javascript - Using AngularJS with BackboneJS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745336748a2654074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论