简体   繁体   中英

In Angular-JS, how can i show a button based on data contained in a selected row?

For the project i'm working on, i've created a table that is populated using a REST service, this is my code:

HTML

<tr ng-repeat="data in response.risultatoRicercaPrimaNota track by $index">
                        <td class="text-center"><input ng-if="data.statoPN" id="idRadioPrimaNota" type="radio" name="groupNamePrimaNota"
                                                       ng-click="selezione($index)" value="{{data.statoPN}}"></td>
                        <td class="text-center">{{data.dataContabile| date:'EEEE'}}</td>
                        <td class="text-center">{{data.dataContabile| date:'dd/MM/yyyy'}}</td>
                        <td class="text-center">{{data.dataRendIntegr| date:'dd/MM/yyyy'}}</td>
                        <td class="text-center">{{data.statoPN}}</td>
                        <td class="text-center">{{data.tipologia}}</td>
                        <td class="text-center">{{data.dataDoc| date:'dd/MM/yyyy'}}</td>
                        <td class="text-center">{{data.dataCompBanc| date:'dd/MM/yyyy'}}</td>
                        <td class="text-center">{{data.testoTestata}}</td>
                        <td  ng-value="$last && caricaPaginazione('cruscottoPrimaNotaTable','1','asc')" class="text-center">
                            {{data.dataInvioSap| date:'dd/MM/yyyy'}}
                        </td>
                    </tr>

With the first column of the table being used as a checkbox.

this is the function inside my js controller:

    $scope.selezione = function (i) {
    $scope.showButton = true;
    $scope.rowselected.idx = i;
    $scope.selected = true;


        CruscottoUtilityService.highlightRow('cruscottoPrimaNotaTable');
    };

Under this table, i have some buttons. How can i show these buttons based on the data i have on the selected row? i should show or hide the buttons based on the string contained inside data.statoPN.

Thank you

I'm not an Angular-js buff, but maybe you could do something like this?

<tr ng-repeat="data in response.risultatoRicercaPrimaNota track by $index" ng-click="onRowClick(data)">

And then in your controller do the logic for showing or hiding the buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM