LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

  
 
Chat
{{chat.username}}

{{chat.text}}

Nothin' here. Say something!

CSS
body {
  background-color:#ccc;
}
JS
var app = angular.module("testapp",[]);

app.factory("DataModel", function() {
  var Service = {};
  
  
  
  return Service;
});

app.controller("ChatController", function($scope) {
  $scope.chatMessages = [];
  
  $scope.formatChat = function(icon,username,text,origDt) {
    var chat = {};
    chat.icon = icon;
    chat.username = username;
    chat.text = text;
    chat.origDt = origDt;
    return chat;
  }
  
  $scope.addChat = function() {
    if ($scope.newChatMsg != "") {
      var chat = $scope.formatChat("http://placehold.it/16x16",
                           "steve",
                           $scope.newChatMsg,
                           new Date());
       
      $scope.chatMessages.push(chat);
      $scope.newChatMsg = "";
    }
    else {
      
    }
  }
  
});

app.filter('reverse', function() {
  return function(items) {
    return items.slice().reverse();
  };
});
Host Instantly Drag and Drop Website Builder

 

Term
Mon, 11/27/2017 - 22:03

Related Codes

Pen ID
Pen ID
Pen ID