admin管理员组

文章数量:1357268

I've built small apps in Angular and Ember and have enjoyed working with both-- the structure and functionality of using these frameworks have made coding up the UI a blast!

I was wondering whether there was a way to embed these apps into a pre-existing legacy site? For Angular, I know you can define a target div as your ng-app. Is there a better way of doing this? What about Ember? Are there any issues I need to look out for with regards to patibility/integration?

I realize these frameworks are primarily meant for SPAs but like I said, I really like the opinionated nature and long-term maintainability benefits of using them.

I tried looking online but I haven't found resources regarding this topic (maybe for good reason). Any input would be appreciated.

I've built small apps in Angular and Ember and have enjoyed working with both-- the structure and functionality of using these frameworks have made coding up the UI a blast!

I was wondering whether there was a way to embed these apps into a pre-existing legacy site? For Angular, I know you can define a target div as your ng-app. Is there a better way of doing this? What about Ember? Are there any issues I need to look out for with regards to patibility/integration?

I realize these frameworks are primarily meant for SPAs but like I said, I really like the opinionated nature and long-term maintainability benefits of using them.

I tried looking online but I haven't found resources regarding this topic (maybe for good reason). Any input would be appreciated.

Share Improve this question asked Feb 20, 2014 at 17:17 vegas-devvegas-dev 4034 silver badges8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

For ember, the proper way is to insert into an existing div. You can declare the div to insert into when defining your ember app as such:

App = Ember.Application.create({
    rootElement: '#divName'
});

For AngularJS you only need to specify where you want the angular part of the code to be piled. By adding:

<div ng-app='MyApplication'></div>

you include the app that you will then import at the end of the index.html file:

<script type='text/javascript' src='myApplication.js'></script>

Then in your application you can create your app and follow the AngularJS module structure from that point on.

var application = angular.module('myApplication', []);

本文标签: javascriptEmbedding EmberAngular apps into preexisting siteStack Overflow