I use Ionic and AngularFire for make a chat, but I have problem: the following error
TypeError: Cannot read property '$add' of undefined at Scope.$scope.sendChat (controllers.js:12)
prevents me to advance in my work. I don't understand where I can found the solution.
This is my code in controller.JS:
angular.module('starter.controllers', ['firebase'])
.factory("Chats", function($firebaseArray) {
var itemsRef = new Firebase("http://ift.tt/1NquD98");
return $firebaseArray(chatsRef);
})
.controller('ChatsCtrl', ['$scope', '$rootScope',
function($scope, Chats, $rootScope) {
$scope.sendChat = function(chat) {
$scope.chats.$add({
user: 'guest',
message: chat.message
});
chat.message = "";
};
}])
This is my code in HTML :
<ion-view view-title="Chats">
<ion-content>
<div class="list">
<a class="item item-avatar">
<img>
<h2>{{ chat.user }}</h2>
<p>{{ data.text }}</p>
</a>
</div>
<form>
<div class="list">
<div class="item item-input-inset">
<label class="item-input-wrapper">
<input type="text" placeholder="Message" ng-model="chat.message">
</label>
<button class="button button-assertive ion ion-ios-chatbubble" ng-click="sendChat(chat)"></button>
</div>
</div>
</form>
</ion-content>
</ion-view>
Can I found a charitable soul to help me?
Aucun commentaire:
Enregistrer un commentaire