Skip to content

Instantly share code, notes, and snippets.

@ajhekman
Last active January 2, 2016 18:09
Show Gist options
  • Save ajhekman/8342102 to your computer and use it in GitHub Desktop.
Save ajhekman/8342102 to your computer and use it in GitHub Desktop.
# create a module
# here we've created a module "myModule" that has a 3rd party dependency "toolkit"
# if we didn't have dependencies, then we would use a blank array "[]"
angular.module('myModule', ['toolkit'])
# file: /app/scripts/services/RemoteResource.coffee
# here we're referencing the already defined 'myModule', and defining the service
# "remoteResource" with a dependency of "$http"(AngularJS builtin)
angular.module('myModule').service 'RemoteResource', ($http)->
retrieve: ()->
$http.get "url"
# file: /app/scripts/controllers/myController1.coffee
# here we're referencing the already defined 'myModule', and defining the controller
# "myController1" with a dependencies "$scope"(AngularJS builtin) and "remoteResource"
angular.module('myModule').controller 'myController1', ($scope, RemoteResource) ->
$scope.resourceText = ""
RemoteResource.retrieve().then (response)->
$scope.resourceText = response.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment