gokatz
4/5/2016 - 6:28 AM

controller learning

controller learning

{
  "version": "0.7.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": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js",
    "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js",
    "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js"
  }
}
<p>Student Academic DataBase</p>

<table border="1">
  <thead>
    <th>Name</th>
    <th>Age</th>		
    <th>Mark</th>
  </thead>
  <tbody>
  {{#each nameAndMark as |entry|}}
		<tr>
      <td>{{entry.name}}</td>
      <td>{{entry.age}}</td>		
      <td>{{entry.mark}}</td>
  	</tr>
	{{/each}}
  </tbody>
</table>
<p>Student Name List</p>

{{#each nameList as |name|}}
	<li> {{name}}</li>
{{/each}}
<h1>Student Details</h1>
<br>
{{#link-to 'one'}}Page 1{{/link-to}}
{{#link-to 'two'}}Page 2{{/link-to}}

<hr>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
  	var age = [21,20,23]
    return age;
  }
});
import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  location: 'none'
});

Router.map(function() {
  this.route('one');
  this.route('two');
});

export default Router;
import Ember from 'ember';

export default Ember.Controller.extend({
  pageOne: Ember.inject.controller('one'),
  nameList: Ember.computed.reads('pageOne.nameList'),
  ageList: Ember.computed.reads('pageOne.model'),
  markList: [100, 78, 91],
  nameAndMark: Ember.computed(function() {
  	var names = this.get('nameList');
    var marks = this.get('markList');
    var ages = this.get('ageList');
    var i, newArr=[];
    for(i=0;i<3;i++) {
    	newArr[i] = {name: names[i], mark: marks[i], age: ages[i]}
    }
    console.log(newArr);
  	return newArr;
  })
});
import Ember from 'ember';

export default Ember.Controller.extend({
  nameList: ['gokul', 'yuvi', 'prsan']
});
import Ember from 'ember';

export default Ember.Controller.extend({
  appName: 'Ember Twiddle'
});