Skip to content

Instantly share code, notes, and snippets.

@gdgupta11
Last active April 4, 2018 13:41
Show Gist options
  • Save gdgupta11/ad42649ccee4175f2e3aca1fad50cf25 to your computer and use it in GitHub Desktop.
Save gdgupta11/ad42649ccee4175f2e3aca1fad50cf25 to your computer and use it in GitHub Desktop.
basic_component_positional_parms
import Ember from 'ember';
export default Ember.Component.extend({
name: Ember.computed('params.[]', function(){
return this.get('params')[0];
}),
id:Ember.computed('params.[]', function(){
return this.get('params')[2];
}),
location:Ember.computed('params.[]', function(){
return this.get('params')[1];
}),
}).reopenClass({
positionalParams: 'params'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
});
export default Router;
// just a sample application showing the usage of static model data in components by passing positional parameters.
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return [
{
name:"Gaurav Gupta",
id: "1",
location: "Bangalore"
},
{
name:"Priyanka Gupta",
id: "2",
location: "Mumbai"
},
{
name:"Garima Gupta",
id: "3",
location: "Burhanpur"
}
]
}
});
import Ember from 'ember';
export default Ember.Route.extend({
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{#each model as |post|}}
{{list-items post.name post.location post.id}}
{{/each}}
{{outlet}}
<br>
<br>
{{yield}}
<p> Id: {{id}} </p>
<p> Name: {{name}} </p>
<p> location: {{location}} </p>
<hr>
{
"version": "0.13.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment