1

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

1 Answer 1

1

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> 
Sign up to request clarification or add additional context in comments.

6 Comments

the button is created by an directive <list can-swipe="true" option-buttons="listButtons"> <item ng-repeat="file in unrelease" item="file">{{file.name}}</item> </list>
Could you post a plunker or jsfiddle? Need to see example of what you are talking about
plnkr.co/edit/aIeXw90m64qLeA05zvuM?p=preview when you click on edit or share i want to hide the buttons again. (swipe left and items to see the options buttons)
In this function onTap-> rather than using "this.hide()", attach a boolean value to object item to show/hide. For each '<div class="item' element add the directive ng-hide that will take this boolean value
I don't want to hide the entire item, just close the swiped options only
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.