I have calling a function in two elements. when I triggering the function an on-click event then also it should be hit once more time for wherever I called that function.
//html
<button type="button" ng-click="{{myFunction()}}">click Me !!</button>
<p ng-show="{{myFunction()}}">{{name}}</p>
//controller
myApp.controller('myController', function ($scope) {
$scope.name = 'Helow World!';
$scope.myFunction = function(){
return true;
};
});
I also tried with ""
instead of {{}}
for two way binding
<button type="button" ng-click="myFunction()">click Me !!</button>
<p ng-show="myFunction()">{{name}}</p>
Problem :
The function will be firing only one time. Show my p
tag does not show.
Solution
I can use a scope object to Show|hide
the p
tag. But that's not my question.
Question
My question is, how to implement Two way binding for event(ng-click)
same as works like ng-repeat,ng-model,mg-show,etc
in angularjs?