【问题标题】:Disable td in bootstrap angularjs depend on role permission在引导 angularjs 中禁用 td 取决于角色权限
【发布时间】:2016-07-06 16:03:16
【问题描述】:

我是 BootstrapAngularJS 的新手,尝试提供权限取决于我试图在表格中隐藏一行 (<td>) 的用户凭据。

abc.html

<td><span type="submit" data-ng-hide="edit" data-ng-click="edit = true" class="glyphicon glyphicon-edit" disabled="disabled"></span>
        <span type="submit" data-ng-show="edit" data-ng-click="edit = false; save()" class="glyphicon glyphicon-save"></span>
        <span type="submit" data-ng-show="edit" data-ng-click="edit = false; cancel()" class="glyphicon glyphicon-remove"></span></td>

我不确定工厂控制器中的 js 是否有人可以帮助我。

【问题讨论】:

    标签: javascript html angularjs twitter-bootstrap


    【解决方案1】:

    tr的属性设置为ng-show=isVisible,并在您的控制器中根据授权结果将其值设置为truefalse

    【讨论】:

      【解决方案2】:

      你的 HTML 应该是这样的

      <table ng-repeat="user in users">
       <tr ng-hide="user.isAuthorized">
        <td>Hey!! I am authorized </td>
       </tr>
      </table>
      

      在你的控制器中,我知道你如何获取用户详细信息(来自 api 的概率),但是你会得到这样的东西

      $scope.users = [{'name': 'John', 'isAuthorized': true},
       {'name': 'Doe', 'isAuthorized': false}];
      

      【讨论】:

        猜你喜欢
        • 2019-11-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-03
        • 2018-05-29
        • 2023-03-15
        • 2013-09-29
        • 2019-12-08
        相关资源
        最近更新 更多