I would like to create a directory structure with Ember.js.
Here's an example of what a URL might look like: folder/1/folder/44/document/3
As you can see, a folder can have several folders inside, as well as documents. I am wondering how I should handle something like this in my router, because earlier my application does not know if there are other folders inside the folder or only documents.
It seems to me that I need to split routes instead of nested routes:
App.Router.map(function() {
this.route('folder', {path: 'folder/:folder_id'});
this.route('document', {path: 'document/:document_id'});
});
If the folder or document has parent folders, the parent folder identifier will be specified in the backend array.
Let take my url example. The deepest nested model is a document with an identifier: 3. In this document model there is folder_id: 44, and folder 44 has parent_folder_ids: [1]. Somehow, my router should know that it should generate an example url from it.
I saw how you can use router.generate to generate URLs, but I'm not sure if this wat is needed, or if queryParams would be a better solution.
( https://github.com/tildeio/router.js#generating-urls )
source
share