Skip to content

Instantly share code, notes, and snippets.

@wshaddix
Created April 7, 2015 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wshaddix/82525200ed5ca0395fde to your computer and use it in GitHub Desktop.
Save wshaddix/82525200ed5ca0395fde to your computer and use it in GitHub Desktop.
Wrong way to do aurelia dependencies
import {HttpClient} from 'aurelia-http-client';
import {Router} from 'aurelia-router';
import {Config} from './my-configurations';
import humane from 'humane';
export class Support {
static inject() { return [HttpClient, Router, Config]; }
constructor(http, router, config){
this.heading = 'Get In Touch';
this.fullName = '';
this.email = '';
this.message = '';
this.http = http;
this.router = router;
this.config = config;
}
sendEmail(){
// create the json object to send to the api
var data = {
fullName : this.fullName,
email : this.email,
topic : 'n/a',
message : this.message
};
// send the data to the api
var client = new HttpClient();
return client.createRequest('supportmessages')
.asPost()
.withBaseUri(config.baseUri)
.withHeader('Content-Type', 'application/json')
.withContent(data)
.send()
.then(response => {
if(response.isSuccess === true)
{
humane.log("Your message has been sent");
this.router.navigate("home");
}
else
{
humane.log(response.statusText);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment