سؤال

I am do research to pick a front MVC frame and finally need to make the decision between Angular and Ember.

The web page contains several sections, like the following,

<div id="section1">{{template1}}</div>
......
<div id="section2">{{template2}}</div>
......
<div id="section3">{{template3}}</div>

Which templates to use is dynamic, all depends on the content. The client needs to query the server. The server will send back the templates to use and client will inject the returned templates in place and render the page.

I am wondering if this is doable with Angular or Ember. If both of them can do this, which one is easier? it will be very helpful if some samples are available to look at.

Any information would be appreciated!

Thanks!

هل كانت مفيدة؟

المحلول

As I lack the 50exp to comment on the question...

I don't know about ember, but in Angular you could use ngInclude or a directive.

However, what do you mean 'query the server'? Do those query points send back the template to use, or determine the URL to the template, or...

It could be that "the Angular way" to accomplish your goal is to use $routeProvider with ngView (be sure to look at the example).

نصائح أخرى

I don't know about ember either, but in angular, you can have a partial template with the ngView directive that loads partial template files, but you can only have one on the page so it's fairly limited.

angular ui router is a module that enables state based routing as well as a uiView directive that is way more flexible. You can have as many as you want on a page, and they can be nested. Each state defines what goes in all your uiView elements and links that state to a url route. It's in early development, but it's very usable as it is now.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top