Ng-clik don't work in header-bar


#1

Hello,
i have a problem with ng-click. when i try it inside ion-view tags it work very well, but when i place it in top bar nothing happen on click. the code is very simple, when i click on this image a div area is showen, when i click again it dissapears.

this is the header code :

<ion-side-menu-content> <ion-header-bar align-title="left" class="bar-assertive"> <h1 class="title"><a href="#/post/list/0"><img src="img/logo.svg"></a></h1> <div class="buttons"> <button class="button button-icon button-clear ion-navicon" menu-toggle="right"></button> </div> <!-- Probleme here --> <img class="button button-clear searched" ng-click="showsr()" src="img/menu/search.svg" /> </ion-header-bar> <ion-nav-view> </ion-nav-view> </ion-side-menu-content> . . .

and this is my function
$scope.showsr = function(){ if ($scope.showSearchForm == false){ $scope.showSearchForm = true; }else{ $scope.showSearchForm = false; } };

Any idea to make it work plaise ?


#2

Have you tried enclosing the img with div tag and place the ng-click on div tag?


#3

yes, i tied div, button, a… but nothing works


#4

i make it work with a simple javascript function, it’s a little nag because i don’t use angular.
I’ll keep it like that until finding a solution


#5

Are you in the same context ? Any console error ? Maybe your function is in a controller out of the template scope …


#6

I have no error in the console, what happen is just the function inside the ng-click is not triggered at all. Maybe because the image is in the index file and not inside the template, and ng-click work only for template elements.


#7

If you have your ng-click in the controller scope should work, I have just try it.

Upload your code to plunker or something like that to have a look.


#8

I traveled this morning for 2 days, as soun as i back (in weekend), i will simplify my code, and upload it in plunker to show you the bug. thank you