Last active
August 29, 2015 13:56
-
-
Save jgwhite/8841164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = Ember.Application.create(); | |
App.Router.map(function () { | |
this.resource('user', function () { | |
this.route('links'); | |
}); | |
}); | |
App.IndexRoute = Em.Route.extend({ | |
beforeModel: function () { | |
this.transitionTo('user.links'); | |
} | |
}); | |
App.UserRoute = Em.Route.extend({ | |
model: function () { | |
return new Ember.RSVP.Promise(function (resolve, reject) { | |
setTimeout(function () { | |
resolve({ | |
name: 'Jo Smith', | |
links: [{ | |
title: 'Google', | |
url: 'http://google.com/' | |
}, { | |
title: 'Example', | |
url: 'http://example.com/' | |
}] | |
}); | |
}, 250); | |
}); | |
} | |
}); | |
App.UserIndexRoute = Em.Route.extend({ | |
model: function () { | |
return this.modelFor('user'); | |
} | |
}); | |
App.UserLinksRoute = Em.Route.extend({ | |
model: function () { | |
return this.modelFor('user').links; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
padding: 1em; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/x-handlebars"> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" id="user"> | |
<h1>User</h1> | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" id="user/index"> | |
<h2>Index</h2> | |
{{name}} | |
</script> | |
<script type="text/x-handlebars" id="user/links"> | |
<h2>Links</h2> | |
<ul> | |
{{#each}} | |
<li><a {{bind-attr href=url}}>{{title}}</a></li> | |
{{/each}} | |
</ul> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment