/app/templates/client/app/main/main.controller(coffee).coffee
CoffeeScript | 22 lines | 17 code | 5 blank | 0 comment | 5 complexity | 1b21c1c73fab8e2a9d8b1c6023d3b09a MD5 | raw file
- 'use strict'
- angular.module '<%= scriptAppName %>'
- .controller 'MainCtrl', ($scope, $http<% if(filters.socketio) { %>, socket<% } %>) ->
- $scope.awesomeThings = []
- $http.get('/api/things').success (awesomeThings) ->
- $scope.awesomeThings = awesomeThings
- <% if(filters.socketio) { %>socket.syncUpdates 'thing', $scope.awesomeThings<% } %>
- <% if(filters.mongoose) { %>
- $scope.addThing = ->
- return if $scope.newThing is ''
- $http.post '/api/things',
- name: $scope.newThing
- $scope.newThing = ''
- $scope.deleteThing = (thing) ->
- $http.delete '/api/things/' + thing._id<% } %><% if(filters.socketio) { %>
- $scope.$on '$destroy', ->
- socket.unsyncUpdates 'thing'<% } %>