PageRenderTime 86ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/app/templates/client/app/main/main.controller(coffee).coffee

https://gitlab.com/javajamesb08/generator-angular-fullstack
CoffeeScript | 22 lines | 17 code | 5 blank | 0 comment | 5 complexity | 1b21c1c73fab8e2a9d8b1c6023d3b09a MD5 | raw file
  1. 'use strict'
  2. angular.module '<%= scriptAppName %>'
  3. .controller 'MainCtrl', ($scope, $http<% if(filters.socketio) { %>, socket<% } %>) ->
  4. $scope.awesomeThings = []
  5. $http.get('/api/things').success (awesomeThings) ->
  6. $scope.awesomeThings = awesomeThings
  7. <% if(filters.socketio) { %>socket.syncUpdates 'thing', $scope.awesomeThings<% } %>
  8. <% if(filters.mongoose) { %>
  9. $scope.addThing = ->
  10. return if $scope.newThing is ''
  11. $http.post '/api/things',
  12. name: $scope.newThing
  13. $scope.newThing = ''
  14. $scope.deleteThing = (thing) ->
  15. $http.delete '/api/things/' + thing._id<% } %><% if(filters.socketio) { %>
  16. $scope.$on '$destroy', ->
  17. socket.unsyncUpdates 'thing'<% } %>