Is there any way to split an Ember.js app across a few files?

后端 未结 4 1677
清歌不尽
清歌不尽 2021-02-02 16:41

I\'ve just written my app.js file and everything is nicely working but the whole file is currently 450 lines long and will be getting bigger.

Is there

相关标签:
4条回答
  • 2021-02-02 16:44

    I use ember-skeleton for my projects.

    To get started simply do the following:

    git clone https://github.com/interline/ember-skeleton.git my-app
    cd my-app
    
    bundle install
    bundle exec rackup
    

    And then go to http://localhost:9292

    Also take a look at the wiki for further build tools and templates.

    0 讨论(0)
  • 2021-02-02 16:49

    You can use RequireJS to load you ember app (including handlebars templates) from different files.

    This answer describes how and also links to a sample app showing how to set things up. I have just tried this approach to one of our websites and it works nicely.

    0 讨论(0)
  • 2021-02-02 16:58

    The standard way to do this is now to use ember-cli. Find more information at http://www.ember-cli.com/

    0 讨论(0)
  • 2021-02-02 17:04

    I was facing the exactly same question two weeks ago, and I didn't wanted to try AMD with requireJS, which seemed a bit complicated for what I wanted to do (and seemed to have advantages but also disadvantages..)

    The simple solution which convinced me is the following :

    I have 3 folders in my js folder : "models", "controllers", and "views" which contains my js "classes", and I have an "index.html" that import all the js files (I used HTML5 boilerplate to get a convenient index.html).

    To be clear, in my index.html, I have at the end of the file something like :

     <script src="js/app.js"></script>
     <script src="js/models/note.js"></script>
     <script src="js/controllers/notesController.js"></script>
     <script src="js/controllers/selectedNoteController.js"></script>
     <script src="js/views/menuView.js"></script>
     <script src="js/views/noteResumeView.js"></script>
     <script src="js/views/noteView.js"></script>
     <script src="js/views/createNoteView.js"></script>
     <script src="js/views/listeNotesView.js"></script>
    

    Hope this help, (and that I didn't misunderstood your question)

    0 讨论(0)
提交回复
热议问题