Created
August 24, 2016 21:47
-
-
Save MariusAndreiTalpos/2b01e42fff6f1d26ebac444706691d50 to your computer and use it in GitHub Desktop.
ionic2
This file contains hidden or 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
{ | |
"name": "qKapital", | |
"app_id": "38bd93b5", | |
"v2": true, | |
"proxies": [ | |
{ | |
"path": "/email", | |
"proxyUrl": "https://api.mailgun.net/v3/sandboxc9e010e60a8d409f8f780e5163d588e9.mailgun.org/messages" | |
} | |
] | |
} | |
This file contains hidden or 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 {Component, Inject} from "@angular/core"; | |
import {TranslatePipe} from "ng2-translate/ng2-translate"; | |
import {FORM_DIRECTIVES, ControlGroup, Validators, AbstractControl} from '@angular/common'; | |
import {CustomValidators} from './custom-validators'; | |
import {Http, Headers, HTTP_PROVIDERS, URLSearchParams, RequestOptions} from "@angular/http"; | |
@Component({ | |
templateUrl: 'build/pages/us-loan/us-loan.html', | |
pipes: [TranslatePipe], | |
directives: [FORM_DIRECTIVES], | |
providers: HTTP_PROVIDERS | |
}) | |
export class UsCitizenPage { | |
post : {}; | |
constructor(private http:Http) { | |
} | |
convertFormObjectToText(formData) { | |
function inspect(formData, props) { | |
var k = []; | |
for (var key in formData) { | |
var keyValuePair = key + ":" + formData[key] + "\n"; | |
k.concat(keyValuePair); | |
k.push(keyValuePair); | |
} | |
return k; | |
} | |
var keyValuePairs = inspect(formData, false); | |
var stringKeyValuePairs = keyValuePairs.toString() | |
console.log(keyValuePairs); | |
this.sendEmail(stringKeyValuePairs); | |
} | |
sendEmail(emailBody) { | |
event.preventDefault(); | |
var url ='/email'; | |
var apiKey = 'key-b2ab456e3dad883739786a57c19b86d5'; | |
var mail = { | |
from : "qKap Mobile Application", | |
to : "[email protected]", | |
subject : "us loan application", | |
text : emailBody | |
}; | |
let body = emailBody; | |
let headers = new Headers(); | |
let options = new RequestOptions({headers: headers}); | |
return this.http.post(url, body, options) | |
.map(response => response.json()) | |
.subscribe( | |
data => body = data, | |
err => console.error(err), | |
() => console.log('email sent') | |
); | |
} | |
onSubmit(evt, formData) { | |
event.preventDefault(); | |
this.sendEmail(formData); | |
debugger; | |
// var XHRResponse = XHR.send("POST", "https://api:[email protected]/v3/IA.qKap.com",{ | |
// "parameters": { | |
// "from": "Mailgun Sandbox <[email protected]>", | |
// "to": "Marius [email protected]", | |
// "subject": "Hello Jordi", | |
// "text": "Congratulations Marius, you just sent an email with Mailgun! You are truly awesome! You can see a record of this email in your logs: https://mailgun.com/cp/log . You can send up to 300 emails/day from this sandbox server. Next, you should add your own domain so you can send 10,000 emails/month for free." | |
// } | |
// }); | |
// console.log(XHRResponse); | |
// debugger; | |
// // console.log('Form submitted is ', formData); | |
// // debugger; | |
// CustomValidators.onlyLetters(formData); | |
// debugger; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment