Reputation: 11
I'm working with a list in angularjs with ionic and I want each item swipe to show options. It's ok through here, but when I tap on one option I want to close the buttons again -- how can i do this in my controller?
$scope.listButtons = [{
Text: "Download",
Type: "button-assertive",
onTap: function(file){
//after tap hide buttons code here..
}
I tried
File.hide();
And
this.hide();
But still cannot hide them
Upvotes: 1
Views: 2165
Reputation: 1995
You are doing DOM manipulation in the controller. Use directives.
pass the show/hide boolean values via scope from the element that uses ng-click, to the element using ng-hide.
Simple example
<button ng-click="listButton.tap=true">{{listButton.Text}}</button>
<button ng-click="listButton.tap=false">{{listButton.Text}} done</button>
<div ng-show="listButton.tap">I am {{listButton.Text}}</div>
<div ng-hide="listButton.tap">I am done {{listButton.Text}}</div>
Upvotes: 1