Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buttons per Row in AngularJS ngTable

I need your help...

I start angularJS and I have a little problem unsolved..

<table>
    <tbody>
        <tr ng-repeat="user in users">
            <td>{{user.name}}</td>
            <td>
                <button ng-click="accept($index)"><strong>accept</strong></button>
                <button ng-click="refuse()"><strong>refuse</strong></button>    
                <p ng-show="showResult($index)"><strong>je suis ton amis</strong></p> 
                <p ng-show="showResult2()"><strong>you refuse me</strong></p>      
            </td>
        </tr>
    </tbody>
</table>

I have a table that contains 2 buttons in each line: ACCEPT and REFUSE with their respective methods accept() and refuse(). I want it to show one sentence on click...

I tried something in Fiddle : http://jsfiddle.net/TBGDu/17/

But the sentence appears many times, but I want it to appear just once where I click. I tried something with tab but for the moment nothing work!

Sorry for my bad spoken language.

like image 520
user2587877 Avatar asked Feb 18 '26 07:02

user2587877


1 Answers

You're inside a loop so you need to use a single variable for each item :

$scope.accept = function(idx){
   $scope.showacceptation[idx] = true;
}

http://jsfiddle.net/TBGDu/24/

like image 116
Florian F Avatar answered Feb 20 '26 21:02

Florian F



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!