I'm trying to make a search input that searches for names in an address book using angularJS but I'm having trouble understanding a problem:
Here's my controller that should hold all the current names:
addressbook.controller('addressBookController', function ($scope) {
$scope.names = [];
});
And here's my repeater that should show the names that matches the query from the search input:
<li data-ng-repeat="name in names | filter: query">{{name}}</li>
Here's the function that adds a contact to the Firebase database:
addContact: function() {
var firstName = document.getElementById('fname').value;
var lastName = document.getElementById('lname').value;
dbContactsRef.push({firstName: firstName, lastName: lastName});
}
But I also want this to push the first and last name into the $scope.names array (for example "Tom Hanks") so my repeater can iterate through it. I'm sure this is very simple to do but I'm drawing blanks and my queries on google come up with no answer. Or if there is a better way of doing this let me know.
pushorsetfunctions or one of the AngularFire equivalents), the data is automatically also available to local code. So if you have adbContactsRef.on('child_added'it will automatically trigger when you calldbContactsRef.push.