0

I would like to know a similar angular function to the one below. I have seen where different people said i should use ng-show .

$$('#tab1').on('show', function () {
myApp.alert('Tab 1 is visible');
 });
explorer
  • 19
  • 5
iTech
  • 97
  • 2
  • 11
  • 1
    I don't think this question is being answered. It seems the request is to define a custom function for when an element is shown, not show or hide the element based on an expression which is what ng-show does. I believe a better match to this question is the Directive answer to [this other post](http://stackoverflow.com/questions/21715256/angularjs-event-to-call-after-content-is-loaded) – packmul3 Apr 12 '17 at 06:21

3 Answers3

2

Hey you should really check out this part of the AngularJS documentation about ng-show. It's a very easy and clear example.

Frank
  • 180
  • 10
1

Angular equivalent directive is:

ng-show 
explorer
  • 19
  • 5
1

If you want to register to an visibilityChanged element instead of only changing the visibility of an element with ng-show you could create a directive with a link function.

angular.module('example', []).directive('example', function() {
    function link(scope, element, attrs) {
        scope.$watch(attrs.ngShow, function() {

            //check if visible
            myApp.alert('Tab 1 is visible');
        });
    }
    return {
       link: link
   };
}]);
kabaehr
  • 1,040
  • 11
  • 18