Template 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>Sample Page</p>
<p>New Page</p>
<h1>Welcome to {{appName}}</h1>
<br>
<a href="https://www.google.co.in/" target="_blank"{{action "logClick" preventDefault=false}}>Go</a>
<h3><button {{action "toggleBody"}}>{{post.title}}</button></h3>
{{#if isShowingBody}}
<p>{{{post.body}}}</p>
{{/if}}
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none'
});
Router.map(function() {
this.route('newpage');
this.route('samplepage');
});
export default Router;
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isShowingBody: false,
post : {title: 'Half Girlfriend', body: 'Half Girlfriend is an Indian English coming of age, young adult romance novel by Indian author Chetan Bhagat.'},
actions: {
toggleBody: function() {
this.toggleProperty('isShowingBody');
},
logClick: function() {
alert('link clicked');
}
}
});