Sha256: 94f629b22c83846da554ed894a30644c47dc1be4f4429e2cede3149a5043576f

Contents?: true

Size: 869 Bytes

Versions: 19

Compression:

Stored size: 869 Bytes

Contents

angular.module 'NgDestroy', ['Factories']

  .directive 'ngDestroy', ($timeout, $compile) ->
    restrict: 'A'
    link: (scope, element, attributes) ->
      element.bind 'click', (event) ->
        scope.destroy(attributes.ngDestroy,attributes.ngContext)
    controller: ($scope, $injector) ->
      $scope.destroy = (modelName,listName) ->
        raw_factory = modelName.split('_')
        factory=[]
        for word in raw_factory
          factory.push(word.charAt(0).toUpperCase() + word.slice(1))
        factory = factory.join('')
        if listName
          list = $scope
          for scope in listName.split('.')
            list = list[scope]
        else
          list = $scope[factory]
        list.splice(list.indexOf($scope[modelName]),1)
        list = $injector.get(factory)
        object = {id: $scope[modelName].id}
        list.delete object

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
material_raingular-0.0.2.6.3 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.6.2 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.6.1 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.6 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.5 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.999999999 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.8 lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.7.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.6.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.5.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.4.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.3.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.2.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.4.1.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.3.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.2.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.1.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.2.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee
material_raingular-0.0.1.alpha lib/assets/javascripts/directives/ngdestroy.js.coffee