<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div id="container">
<section ng-controller="getContactsCtrl">
<h1> Contact Us</h1>
<br>
<h2> If you wish to contact us about prices and information, kindly fill in the form below. </h2>
<br>
<form class="form-group" id="customForms" ng-controller="getContactsCtrl">
<label> E-mail </label>
<input id="customFormsInput" class="form-control" ng-model="contact.email" type="email" placeholder="E-mail goes here" required/>
<br>
<label> Mobile Number </label>
<input id="customFormsInput" class="form-control" ng-model="contact.mobile" type="number" placeholder="Your number goes here" required/>
<br>
<label> How may we be of service? </label>
<br>
<textarea rows="4" cols="100" ng-model="contact.text" type="text" placeholder="Insert text here" required>
<!-- User text -->
</textarea>
<br><br>
<button class="btn btn-primary" ng-click="newContact(contact)"> Submit </button>
<br> <br><p> {{queryMsg}} </p>
</form>
<h2> You can also visit us at our premises at Smart City, Xghajra. </h2>
<br>
<div id="googleMap" style="width:500px;height:380px;"></div>
<br><br>
</section>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
myApp.controller('getContactsCtrl', ['$scope', '$http', function($scope, $http)
{
$scope.newContact = function(contact) {
console.log(contact);
$scope.queryMsg= ""; //displays if sent or not in html form
//post is used to create
$http.post('model/addContact.php', contact).success(function(data) {
if (data && contact != null)
{//row inserted
$scope.queryMsg = "Query has been sent successfully.";
console.log("Query received in DB");
$scope.contact=""; //clear text again after submit is pressed
}
else
{
$scope.queryMsg = "We were unable to fetch your query at this time.";
console.log("Query not received");
}
})
};
}
]);
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.