首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Uib-tabset - http成功时更改

Uib-tabset - http成功时更改
EN

Stack Overflow用户
提问于 2017-02-28 17:07:16
回答 1查看 166关注 0票数 0

我有模式框,在模式框中我有标签。在第一个选项卡上,我需要选择项目,并在单击按钮NEXT时将其分配给用户。如果成功,则自动更改项目配置所在的下一选项卡。如果服务器响应出现错误,请停留在相同的选项卡上。

这是我的模式框html

代码语言:javascript
复制
<div class="modal fade" id="myModal2" data-toggle="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content" style="width: 650px;">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <uib-tabset active="active">
                    <uib-tab index="0" heading="Select benches">

                        <div class="modal-body">
                            <label for="type" class="col-sm-3 control-label">Selected buyers: </label>someone@gmail.com

                            <div class="tablicaPridruzivanjeKlupaKlijentu">
                                <div style="padding-top: 10px;">
                                    <button ng-click="oznaciSve()" ng-model="option">check all</button>
                                    <button ng-click="odznaciSve()">uncheck all</button>
                                </div>
                                <form name="addingBench">
                                    <table class="table" style="width: 100%">
                                        <thead>
                                            <tr class='active'>
                                                <th>Select items</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr ng-repeat="bench in freeBenchesForDistributors">
                                                <th>
                                                    <input type="checkbox" checklist-model="selected.freeBenchesForDistributors" checklist-value="bench.id">
                                                    {{items.id}}
                                                </th>
                                            </tr>
                                        </tbody>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </uib-tab>
                    <uib-tab index="1" heading="Config">
                        <h6 style="padding-left: 10px;"><b>Info}</b></h6>
                        <form editable-form name="tableformConfig" shown="true" onaftersave="sendBenchAndConfigDistributors()" oncancel="cancel()">
                            <table class="table tableDistributorConfig col-sm-12" style="width: 100%">
                                <thead>
                                <th>
                                    <button type="button" class="btn btn-default" ng-show="!tableformConfig.$visible" ng-click="tableformConfig.$show()">
                                        Edit
                                    </button>
                                </th>
                                </thead>

                                <thead> 
                                <th>
                                    <button type="submit" ng-show="tableformConfig.$visible" ng-disabled="tableformConfig.$waiting" class="btn btn-primary">
                                        Save
                                    </button>
                                </th>
                                </thead>

                            </table> 
                        </form>
                    </uib-tab>
                </uib-tabset>
                <div class="modal-footer">
                    <button ng-hide="enable" type="button" class="btn btn-default btn-sm" ng-click="active = 1; change(); itemsForClient()">Next</button>
                    <button ng-click="changeBackNext()" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>

    </div>

和我的控制器

代码语言:javascript
复制
$scope.itemsForClient = function () {
        var data = [];
        angular.forEach($scope.selected.freeItemsForDistributors, function (key, value) {
            data.push({id: key, distributor: $rootScope.selectedDistributorsIdForAddingItems});
        });
        var json = JSON.stringify(data);
        var config = {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'X-HTTP-Method-Override': 'PATCH'
            }
        };

        $http.post(serviceBase + 'control-board/items/bulk', data, config)
                .success(function (data, status, headers, config) {
                    Notification.success({message: $filter('translate')('ITEMS_ADDED_SUCCESSFULLY'), delay: 3000, positionY: 'bottom', positionX: 'right'});
                })
                .error(function (data, status, header, config) {
                    Notification.error({message: $filter('translate')('ITEMS_ADDED_ERROR'), positionY: 'bottom', positionX: 'right'});
                });
    };

Thnx

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-02-28 18:22:37

请进行以下更改

在视图中,将“下一步”按钮更改为

代码语言:javascript
复制
 <button ng-hide="enable" type="button" class="btn btn-default btn-sm" ng-click="change(); itemsForClient()">Next</button>

而不是

代码语言:javascript
复制
 <button ng-hide="enable" type="button" class="btn btn-default btn-sm" ng-click="active = 1; change(); itemsForClient()">Next</button>

并按如下方式更新$http.post

代码语言:javascript
复制
$http.post(serviceBase + 'control-board/items/bulk', data, config)
                .success(function (data, status, headers, config) {
                     $scope.active = 1;
                    Notification.success({message: $filter('translate')('ITEMS_ADDED_SUCCESSFULLY'), delay: 3000, positionY: 'bottom', positionX: 'right'});
                })
                .error(function (data, status, header, config) {
                    Notification.error({message: $filter('translate')('ITEMS_ADDED_ERROR'), positionY: 'bottom', positionX: 'right'});
                });
 };
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42504391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档