Skip to content

Instantly share code, notes, and snippets.

@feanor07
Last active April 11, 2017 16:47
Show Gist options
  • Save feanor07/b7163b9567515542e478b936a605c9d7 to your computer and use it in GitHub Desktop.
Save feanor07/b7163b9567515542e478b936a605c9d7 to your computer and use it in GitHub Desktop.
stackoverflow question#43350970
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
sendRequest() {
let requestParams = {url: 'https://www.randomtext.me/api/lorem/ul-5/5-15',
type: 'GET', dataType:'json'};
Ember.$.ajax(requestParams).then((json)=>{
console.log(json);
this.set('randomText', Ember.String.htmlSafe(json.text_out));
});
}
}
});
<h1>Random Text</h1>
{{randomText}}<br>
<button {{action "sendRequest"}}>Do Test</button>
{
"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": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment