-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
27 lines (27 loc) · 1.11 KB
/
index.html
File metadata and controls
27 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<html ng-app="myapp">
<head>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js'></script>
<script src='https://cdn.firebase.com/v0/firebase.js'></script>
<script src='https://cdn.firebase.com/libs/angularfire/0.6.0/angularfire.min.js'></script>
<link rel='stylesheet' type='text/css' href='css/chat.css'>
</head>
<body ng-controller="MyController">
<div id="messagesDiv">
<div ng-repeat="msg in messages"><em>{{msg.from}}</em>: {{msg.body}}</div>
</div>
<input type="text" ng-model="name" placeholder="Name">
<input type="text" ng-model="msg" ng-keydown="addMessage($event)" placeholder="Message...">
<script>
var app = angular.module("myapp", ["firebase"]);
function MyController($scope, $firebase) {
var ref = new Firebase("https://k7ltqx50lsg.firebaseio-demo.com/");
$scope.messages = $firebase(ref);
}
$scope.addMessage = function(e) {
if (e.keyCode != 13) return;
$scope.messages.$add({from: $scope.name, body: $scope.msg});
$scope.msg = "";
};
</script>
</body>
</html>