Hi,
I would like to set ID to equal the ID that is being output in my console
below is my code for adding from a form please help:
$scope.addFormSubmit = function(){
console.log('adding contact');
// Assign values
if($scope.id){var id = $scope.id} else {var id = null;}
if($scope.name){var name = $scope.name} else {var name = null;}
if($scope.company){var company = $scope.company} else {var company =
null;}
if($scope.homephone){var home_phone = $scope.homephone} else {var
home_phone = null;}
if($scope.mobilephone){var mobile_phone = $scope.mobilephone} else {var
mobile_phone = null;}
if($scope.street_address){var street_address = $scope.street_address}
else {var street_address = null;}
if($scope.city){var city = $scope.city} else {var city = null;}
if($scope.county){var county = $scope.county} else {var county = null;}
if($scope.email){var email = $scope.email} else {var email = null;}
//Build object
$scope.contacts.$add({
id: id,
name: name,
company:company,
email: email,
phones: [{
mobile: mobile_phone,
home: home_phone
}],
address: [{
street_address: street_address,
city: city,
county: county
}]
}).then(function(ref){
*var id = ref.push();*
* console.log("added contact with ID"+id);*
//clear form
clearFields();
//hide form
$scope.addFormShow = false;
//Message user
$scope.msg = "contact added";
})
}
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.