Thanks for the reply Sander. My requirement is to actually have a function 
that will determine the visibility based on some logic. So css is not an 
option for me. I did try to compile as below but 
that did not help. 
Here i am attachinh this directive to a Button and test() is a function 
that is available in the controller in the context of which the Button will 
be rendered. The button needs to be hidden/shown based on some computation 
in the test() function.


angular.module('testApp')

    .directive('nmUiEditorShowControl', function($document, $rootScope) {

        return {

            restrict: 'A',

            link: function(scope, element, attrs) {

                    element.attr('ng-show', 'test()');

                    element = $compile(element)(scope);

                    scope.$apply();

               // element.addClass('ng-hide');

                   

                

            }

        };

    });

On Tuesday, October 28, 2014 5:37:27 AM UTC-7, Sander Elias wrote:
>
> Hi Sonal,
>
> If you add directives to an existing, and already compiled directive, you 
> need to recompile it.
> In this case, I would not do that, but just use some style manipulation to 
> show/hide the element.
>
> something like: `element.style.display="none";`
>
> Drop me a note if you want an elaborate example,
>
> Regards
> Sander
>
>
>

-- 
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/d/optout.

Reply via email to