Sha256: d0500f5349d07d9fc80cd2495f17b5f9407f7b3b57cd8d2bcbd23c839af96607

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

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)
    @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%>

])

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
angular_velocity-1.0.0 lib/generators/angular_velocity/service/templates/service.coffee
angular_velocity-0.0.6alpha lib/generators/angular_velocity/service/templates/service.coffee