/client/app/main/main.controller.js
JavaScript | 27 lines | 22 code | 5 blank | 0 comment | 1 complexity | c77f6dfade3af698bfc29570f5343a4d MD5 | raw file
- 'use strict';
- angular.module('miningWebuiApp')
- .controller('MainCtrl', function ($scope, $http, socket) {
- $scope.awesomeThings = [];
- $http.get('/api/things').success(function(awesomeThings) {
- $scope.awesomeThings = awesomeThings;
- socket.syncUpdates('thing', $scope.awesomeThings);
- });
- $scope.addThing = function() {
- if($scope.newThing === '') {
- return;
- }
- $http.post('/api/things', { name: $scope.newThing });
- $scope.newThing = '';
- };
- $scope.deleteThing = function(thing) {
- $http.delete('/api/things/' + thing._id);
- };
- $scope.$on('$destroy', function () {
- socket.unsyncUpdates('thing');
- });
- });