ngDisabled用法學習記錄

功能很強大,記錄一下java

ngDisabled 用在button上是最有效的,我以前用在了input 框、span中都沒有起到做用,可能只能在button上使用吧,這是用表達式來判斷,也可使用方法來進行判斷,好比ng-disabled="WorkInProgress()",而後在js 中寫內容,將該方法判斷爲true或者false就能夠達到效果,個人例子中使用了angular-MDspa

 <table class="table table-bordered table-striped table-condensed">
    <thead>
        <th ng-repeat="column in vm.columns" ng-if="!column.hidden" ng-click="vm.sort.toggle(column)"
            ng-class="{sortable: column.sortable !== false}" style="text-align: center;">
            {{column.label}}
            <i ng-if="column.name === vm.sort.column && vm.sort.direction"
               class="glyphicon {{vm.sort.direction|orderClass}}"></i>
        </th>
    </thead>
    <tbody>
        <tr ng-repeat="reg in vm.result | filter:vm.filter | orderBy:vm.sort.column:vm.sort.direction===-1 | paging:vm.page.index:vm.page.size">
            <td> {{ reg.ID }}</td>
            <td> {{ reg.jar }}</td>
            <td> {{ reg.className }}</td>
            <td> {{ reg.runType }}</td>
            <td> {{ reg.TaskType }}</td>
            <td> {{ reg.Gid }}</td>
            <td>
                <button class="btn btn-sm btn-primary" ng-disabled="reg.TaskType='boot'" ng-click="runJob(reg.ID)">
                    <md-tooltip md-direction="top">
                        啓動
                    </md-tooltip><i class="fa fa-play"></i>
                </button>
                <button class="btn btn-sm btn-danger" ng-disabled="reg.TaskType='boot'" ng-click="unRegistJob(reg.ID)">
                    <md-tooltip md-direction="top">
                        註銷
                    </md-tooltip><i class="fa fa-ban"></i>
                </button>
            </td>
        </tr>
    </tbody>
</table>
相關文章
相關標籤/搜索