0

If i use like following,I got what i need.. Here is the code.

<style>
  .moreMenu {
        position: absolute;
        right: 0px;
        z-index: 10;
        padding: 10px;
        color: #666;
        border-radius: 0 0 0 4px;
        background: #FFF;
        display: none;
        border-top: 1px solid #DDD;
    }
</style>
 <i class="fa fa-ellipsis-v tbButton otherOptions rightSide"  aria-hidden="true"></i>
    <div class="moreMenu">
          heloo
   </div>
<script>
  $(".otherOptions").click(function () {

                $(".moreMenu").slideToggle("fast");
            });
</script>

But if i use ng-if condition,

 <i class="fa fa-ellipsis-v tbButton otherOptions rightSide"  aria-hidden="true" ng-if="member==''"></i>

click function is not working.

TGrif
  • 5,725
  • 9
  • 31
  • 52
athi
  • 123
  • 9

3 Answers3

1

I solved the issue..

<i class="fa fa-ellipsis-v tbButton otherOptions rightSide"  aria-hidden="true" ng-if=members==''" ng-click="mymore()"></i>


// controller
     $scope.mymore = function(){    
        $(".moreMenu").slideToggle("fast");
    }

Thanks all for the informations...

Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
athi
  • 123
  • 9
  • But appreciate your works. But do you know why the click does not working if you are using `ng-if`? – Ramesh Rajendran Jan 08 '18 at 10:48
  • @RameshRajendran my guess it that unlike `ng-show`, `ng-if` doesn't hide the content but [removes DOM entirely](https://docs.angularjs.org/api/ng/directive/ngIf#overview). Since jQuery isn't part of AngularJS's digest cycle, the div with `moreMenu` class is not rendered yet for `$(...)` to grab it – Aleksey Solovey Jan 08 '18 at 10:55
0

It would be better to use ng-click but if you need to use jQuery's click event, you can add a filtered click event to the body:

$('body').on('click', '.otherOptions', function() {
  $('.moreMenu').slideToggle('fast');
});

this will add an event handler on the body but will only trigger if the event bubbles up from the otherOptions element. This is an approach to handling dynamic content with jQuery events

George
  • 1,706
  • 1
  • 11
  • 12
0

@athi is your answer is a proper answer. But as per the question I have answered here use ng-show instead of ng-if.

angular.module("a",[]).controller("ac",function($scope){
   

    });
.otherOptions
{
color: #666;

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="a" ng-controller="ac">
 <input class="otherOptions" type="button" value="hello" ng-click="mymore()" ng-show=true>
    <div class="moreMenu">
          heloodfg
   </div>
   </div>
 <script>
 $(".otherOptions").click(function () {
        $(".moreMenu").slideToggle("fast");
    });
 </script>
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234