5 ms·
One thing that I like about Knockout is that you can easily drop it into a legacy site, allowing you to have some pages that use it and others that don't. Forg
by chidevguy 13y ago
One thing that I like about Knockout is that you can easily drop it into a legacy site, allowing you to have some pages that use it and others that don't. Forgive my naivete, but is this something that is easy to do with Ember or Angular as well?
- machty 13y agoYes. Both Angular and Ember support this pattern pretty effortlessly.
- bmelton 13y agoWithout knowing the specifics, the best answer I can come up with here is that it's Javascript -- so yeah, you can write it affect parts of the page, or all of the page. You can have it control just the navigation bar on a site, or the whole site altogether. There are caveats here -- if you have the library loaded from any page with html5 location mode enabled, it'll take over link-handling on those pages. With Angular, it's easy to circumvent by adding a 'target' attribute to the links, but on a legacy site, that might mean having to touch every page that Angular doesn't already exist on, which would be a chore. The alternative is to not enable HTML5 location mode (so links are to #/link/) or to adjust the targets on links that aren't meant to be handled by JS. All summed up though, while it may not be written anywhere, I've always gotten the feeling that Angular prefers to own the entire page, loading partials into views where appropriate, and using separate controllers for other portions of the page. That said, it can work either way, but does take some extra special care.
- machty 13y ago"allowing you to have some pages that use it and others that don't" Your response seems to dig into a different (though related) issue. If the question is whether, given a whole website, whether angular/ember can exist only on certain pages, but not all pages, then the answer is Yes.
- adambard 13y agoAngular yes, Ember perhaps not. I this wrote briefly on the subject recently: http://adambard.com/blog/angular-in-the-small/ http://adambard.com/blog/angular-in-the-small/
- machty 13y agoEmber yes.
- bcardarella 13y agoAngular definitely not.
- caplingerc 13y agoin-co-rrect
- lhorie 13y agoI've been working on porting mission critical parts of a 10-year-old+ app over to Angular; some of the syntax is clunky but it's definitely doable
- gcv 13y agoI have successfully done this with Angular. It was easy and convenient. No idea about Ember, so far I've only watched its tutorial video.
- dickeytk 13y agothis is one of the nice things about angular. You can just drop it in to make a component of an existing site use angular. I attempted to get that to work with ember, but I don't think it's possible.
- machty 13y agoIt is possible, and just as easy with Ember.
- throwa 13y agosee an example of using emberjs for only some pages: http://www.ryandao.net/portal/content/emberjs-how-use-ember-within-rails-page http://www.ryandao.net/portal/content/emberjs-how-use-ember-...
- taude 13y agoEDIT: whoops, I was answering about Knockout vs Angular here, not Ember. I think it's actually easier in angular, because you can set the ng-app parameter at the point in the DOM tree you want to bind to the Angular portion of the app. (ng-app is similar to ko.applyBindings, except that unlike KO, with Angular don't have to worry about having parent DOM bindings clash with child DOM binding applications.).