Recently I am trying to learn AngularJs and CoffeeScript by writing a small app.
After reading some blogs I can write Angular controller and service with CoffeeScript Class style. The following is a example of controller.
libr = angular.module('libr.controllers.main', [])
class MainController
@$inject: ['$scope']
constructor: (@$scope) ->
@$scope.test = test
test: ()->
console.log 'Hello'
libr.controller 'MainCtrl', MainController
And it works well.
But I can't convert a Angular factory as following successfully with using Coffee Class style.
var app = angular.module('app', ['ngResource', 'ngRoute']);
// Some APIs expect a PUT request in the format URL/object/ID
// Here we are creating an 'update' method
app.factory('Notes', ['$resource', function($resource) {
return $resource('/notes/:id', null,
{
'update': { method:'PUT' }
});
}]);
This code is a example code from AngularJs official website:http://docs.angularjs.org/api/ngResource.$resource
Could anyone help me to convert it to CoffeeScript Class style?