Hello list users,

Let's say HTML gets generated from this HAML markup:
%fieldset{ maskable: 'processing' }

Then, i have this directive:
angular.module('PQRReusable.directives')
.directive(
  'maskable',
  [ '$parse', ($parse) ->
      restrict:       'A'
      scope:          {}
      link: ($scope, element, attrs) ->
        $scope.$parent.$watch $parse(attrs.maskable), (value) ->
          if value then element.mask('Loading...') else element.unmask()
  ]
)

As you can see, i'm trying to let the directive invoke some jQuery magic over 
the dom element (With the help of the "jQuery.loadmask" plugin).

The controller of the view where this lives has a $scope.processing variable, 
that is being set to true or false wether data is being manipulated / loaded.
Everything is working pretty much as i would like it to work, and a mask with 
"Loading..." is correctly applied to the block where the directive compiled.

But i'm wondering... Is it the "angular-way" to do such thing? i feel that 
using a watch for this purpose might be kind of wrong... For instance, how 
would behave such directive (performance-wise) in a table with a lot of 
records, each one having a masking capability? Am i doing anything wrong?

Also, do i need to do: scope: { maskable: '=' } or anything similar to isolate 
the directive scope (it only needs one way binding for the watch)?

Thanks a lot for your help,
Pierre.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to