Skip to content

Instantly share code, notes, and snippets.

@marvinosswald
Created August 12, 2014 12:59
Show Gist options
  • Save marvinosswald/64f5a8032b77825e9b95 to your computer and use it in GitHub Desktop.
Save marvinosswald/64f5a8032b77825e9b95 to your computer and use it in GitHub Desktop.
Emberjs nested child view example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/tags/v1.5.1/ember.min.js"></script>
<style id="jsbin-css">
/* Put your CSS here */
html, body {
margin: 20px;
}
</style>
</head>
<body>
<script type="text/x-handlebars" data-template-name="index">
<h2>Welcome to Ember.js</h2>
<div>
{{#each item in model}}
{{#linkTo 'index.details' item}}
{{item}}
{{/linkTo}}
{{/each}}
</div>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="details">
{{content}}
</script>
<script id="jsbin-javascript">
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
this.resource('index',{path: '/'},function(){
this.route('details',{path: '/details/:id'});
});
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue'];
}
});
App.IndexDetailsRoute = Ember.Route.extend({
templateName: 'details',
model: function(params) {
return params.id;
}
});
</script>
</body>
</html>
/* Put your CSS here */
html, body {
margin: 20px;
}
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
this.resource('index',{path: '/'},function(){
this.route('details',{path: '/details/:id'});
});
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue'];
}
});
App.IndexDetailsRoute = Ember.Route.extend({
templateName: 'details',
model: function(params) {
return params.id;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment