I'm currently exploring the functionality of AngularFire and trying to store a first name and last name in my Firebase database. While I successfully managed to create an input field for the first name and save it in Firebase, I'm facing challenges when adding a last name input field. Here is where I am at the moment:
HTML
<section ng-controller="premiercontrolleur">
<ul>
<li ng-repeat="client in clients">
<input ng-model="client.prenom" ng-change="clients.$save(client)" />
<input ng-model="client.nom" ng-change="clients.$save(client)" />
<button ng-click="clients.$remove(client)">X</button>
</li>
</ul>
<form ng-submit="addClient(newClientText)">
<input type="text" placeholder="First Name" ng-model="newClientText.prenom" />
<input type="text" placeholder="Last Name" ng-model="newClientText.nom" />
<button type="submit">Add Client</button>
</form>
</section>
Javascript
var app = angular.module("crmfirebase", ["firebase"]);
app.controller("premiercontrolleur", function($scope, $firebase) {
var ref = new Firebase("https://mydirebaseurl.firebaseio.com/clients");
var sync = $firebase(ref);
$scope.clients = sync.$asArray();
$scope.addClient = function(prenom, nom) {
$scope.clients.$add({prenom: prenom, nom: nom});
}
});
Upon submitting, I encountered this error:
Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('submit') does not support selection.