Created
April 7, 2015 22:02
-
-
Save wshaddix/82525200ed5ca0395fde to your computer and use it in GitHub Desktop.
Wrong way to do aurelia dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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