Skip to content

Instantly share code, notes, and snippets.

@smile921
Last active December 28, 2017 05:01
Show Gist options
  • Save smile921/654b77d69e86e750ee189e68f5e95577 to your computer and use it in GitHub Desktop.
Save smile921/654b77d69e86e750ee189e68f5e95577 to your computer and use it in GitHub Desktop.
ddau-v1
import Ember from 'ember';
export default Ember.Component.extend({
oneAct:'oneAction',
actions:{
oneAct(){
this.sendAction('onAct');
}
}
});
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() {
this.route('ddauOne');
});
export default Router;
import Ember from 'ember';
export default Ember.Route.extend({
one:1,
actions:{
oneAction(){
this.set('one',this.get('one')+1);
}
}
});
import Ember from 'ember';
export default Ember.Route.extend({
secret: 'nothing',
model() {
return {
firstName : 'John '+ this.get('secret'),
lastName : 'Doe',
email : '[email protected]',
address : {
street : '406 Goldner View',
city : 'Newtown',
code : '123-567'
}
};
},
actions: {
changeSecret( secPara ){
let sec = this.get('sec');
console.log(sec);
this.set('sec', secPara )
},
countInc: function(){
console.log(' counter + + ');
},
changeName() {
this.set('secret', 'James');
console.log('change clicked ');
}
}
});
<h1>Welcome to {{appName}}</h1>
<hr>
<br>
<br>
{{outlet}}
<br>
<br>
{{yield}}
<button onclick="{{action 'oneAct'}}">oneAct </button>
<h1>ddau one actions in route</h1>
<hr>
{{one}}
{{#ddau-one-component}}
{{/ddau-one-component}}
<h2> Hello Index </h2>
<hr>
<input value ={{secret}}>
<button {{action "countInc"}}> counter </button>
<hr>
<h2>My Details</h2>
<ul>
<li>First Name : {{model.firstName}} <b>为什么双向绑定不起作用呢?</b></li>
<li>Last Name : {{model.lastName}}</li>
<li>Email : {{model.email}}</li>
</ul>
<p>Address Details</p>
<ul>
<li>Street Address : {{model.address.street}}</li>
<li>City : {{model.address.city}}</li>
<li>Code : {{model.address.code}}</li>
</ul>
<button {{action "changeName"}} >Change Name</button>
<h2> data down </h2>
<p>pass the data to the component with reopenPositionalParams </p>
<hr>
{{#link-to 'ddauOne' class="button"}}ddau one {{/link-to}}
{
"version": "0.12.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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment