简体   繁体   English

在 Angular-JS 中,如何根据所选行中包含的数据显示按钮?

[英]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:对于我正在处理的项目,我创建了一个使用 REST 服务填充的表,这是我的代码:

HTML 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:这是我的 js controller 中的 function:

    $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.我应该根据 data.statoPN 中包含的字符串显示或隐藏按钮。

Thank you谢谢

I'm not an Angular-js buff, but maybe you could do something like this?我不是 Angular-js 爱好者,但也许你可以做这样的事情?

<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.然后在您的 controller 中执行显示或隐藏按钮的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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