Blame view

public/js/controllers/ForumDirCtrl.js 1.01 KB
12162cc1   Geoffrey PREUD'HOMME   Liste de conversa...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  angular.module('ForumDirCtrl', ['SessionsServ', 'ForumServ', 'NotifyServ']).controller('ForumDirCtrl', ['$scope', 'SessionServ', 'ForumServ', 'NotifyServ',
      function ($scope, SessionServ, ForumServ, NotifyServ) {
          $scope.convs = [];
          $scope.formData = {};
  
          $scope.session = SessionServ.cur;
          SessionServ.onChange(function () {
              $scope.session = SessionServ.cur;
          });
  
          ForumServ.getConvs(function(err, convs) {
              if (!err)
                  $scope.convs = convs;
          });
  
          $scope.createConv = function () {
              ForumServ.createConv($scope.formData, function(err, conv) {
                  if (!err)
9378de0d   Geoffrey PREUD'HOMME   Affichage d'une c...
19
                      $scope.formData = {};
12162cc1   Geoffrey PREUD'HOMME   Liste de conversa...
20
21
22
23
24
25
26
27
28
29
30
31
32
                      $scope.convs.push(conv);
              });
          };
  
          $scope.deleteConv = function (index) {
              ForumServ.deleteConv($scope.convs[index]._id, function(err) {
                  if (!err)
                      $scope.convs.splice(index, 1);
              });
          };
  
      }
  ]);