I'm trying to process the submitted data object from a form but I'm stuck. I have done some researches on this site and spent hours reading but I didn't get any answer. I can get the form data without a problem, the issue is when a customer registers guests at two or more hotels. In the pre tags it will show hotel_name:{"hotelx", "hotely"}. I want to store this as JSON in my lodging file but when my controller receives the form data object, how do break into it and get what I need, so I can push it onto the file?
<div class=" col-md-12">
<div class="md-form">
<input type="text" id="Not_Listed" class="form-control" ng-model="lodgingRegistration.not_listed" placeholder="Enter hotel name if not listed below">
<label for="Not_Listed"></label>
</div>
<div class="md-form col-md-6" ng-repeat="x in lodging">
<input type="checkbox" id="{{x.hotel_name}}"
ng-model="lodgingRegistration.hotel_name[x.hotel_name]">
<label for="{{x.hotel_name}}">{{x.hotel_name}}</label>
</div>
</div>
<div class="text-center">
<button class="btn btn-deep-purple" ng- click="register(lodgingRegistration)">Submit</button>
</div>
<h3>Captured Form Data:</h3>
<pre>{{lodgingRegistration | json}}</pre>
Here is my controller code
$scope.register = function(lodgingRegistration){
// something must go here to break into the object/array before I push?
$scope.registered.push(lodgingRegistration);
console.log(lodgingRegistration);
}
and here is my display, most of works but I can't access the dummy data in the file either, which is an array of hotel_name
<tbody>
<tr ng-repeat="x in registered | filter:SearchHotel"
<th scope="row">{{$index +1}}</th>
<td>{{x.event_name}}</td>
<td>{{x.team_name}}</td>
<td>{{x.sport}}</td>
<td>{{x.hotel_name}}</td>
</tr>
</tbody>
I know I need to change how to access the
x.hotel_name
, I tried nest
ng-repeat with
y in x.hotel_name
but it didn't work. I'd like to store this as JSON using Firebase but if I can't I'll have to go back to PHP and I really don't want to do that, any help is much appreciated.