lib/generators/angular_velocity/service/templates/service.coffee in angular_velocity-0.0.3alpha vs lib/generators/angular_velocity/service/templates/service.coffee in angular_velocity-0.0.4alpha

- old
+ new

@@ -1,8 +1,21 @@ -angular.module('<%= application_name %>Service', []).factory( '<%=file_name.camelize %>', [ '$scope','$http', +angular.module('<%= application_name %>Service', []).factory( '<%= file_name.camelize %>', [ '$http', ($http, $scope) -> class <%=file_name.camelize %> constructor: (data) -> @instantiate(data) instantiate: (data) -> @attributes = data - angular.extend(@, data) + angular.extend(@, data) + @all: () -> + <%=file_name.pluralize %> = [] + $http.get("api/<%= file_name.pluralize %>").then( (response) -> + <%=file_name.pluralize %>.push new <%=file_name.camelize %>(params) for params in response.data + ) + <%=file_name.pluralize %> + @find: (<%=file_name %>Id) -> + <%=file_name%> = new <%=file_name.camelize %> + $http.get('api/<%= file_name.pluralize %>/<%=file_name %>Id').then( (response)-> + <%=file_name%>.instantiate(response.data) + ) + <%=file_name%> + ]) \ No newline at end of file