Angularjs-插入表单内的下拉列表:如何在提交表单之前将项目添加到下拉列表?

问题描述 投票:0回答:1
  1. 我有一个模式文本输入页面,除其他字段外,还有一个“作者”下拉列表
  2. 有时会在“作者”下拉列表中没有所需的作者项目
  3. 因此,用户必须关闭模式文本输入页面,进入模式“作者”输入页面以插入新作者,然后,回到模式文本输入页面以提交表单。

enter image description here

在下面的代码中调用模式文本输入页面:

vm.popupAddTextForm = function () {        
    var modalInstance = $modal.open({
        templateUrl: '/add_text_modal/add_text_modal.view.html',
        controller: 'add_text_modalCtrl as vm',
        resolve : { modalDati : function () {   
            return {datatips : vm.datatips,
                datatipbyid :  vm.datatipbyid,
                datasubtips : vm.datasubtips,
                dataauts : vm.dataauts  }
            }
        }
    });

是否可以通过单击“添加新作者”按钮直接从模式文本输入页面调用模式“作者”输入页面?插入新作者后,如何更新相对下拉列表?

提前打个招呼。

angularjs list forms submit dropdown
1个回答
0
投票

Thnks Maxim Shoustin和JoãoFé我遵循了您的建议,我明白了!我希望可以帮助某人共享流程:

  1. 我在html中插入btn以调用vm.popupAddAutForm():

 <div class="col-sm-4"><a ng-click="vm.popupAddAutForm()" class="btn btn-default pull-right" style="width: 100px;">Nuovo Autore</a></div>
  1. 我在模式文本输入页面中放入了调用vm.popupAddAutForm()的代码:

//If Author is not present in the relative dropdown list 
        //I invoke modal author entry page 
        //(the modal text entry page is hidden and all data field remain in stand-by)
        vm.popupAddAutForm = function () {
            var modalInstance = $modal.open({
                templateUrl: '/add_aut_modal/add_aut_modal.view.html',
                controller: 'add_aut_modalCtrl as vm'
            }); 
            //after author insert I recall RestFul API to retrieve authors again and 
            //update the relative dropdown list 
            modalInstance.result.then(function(data) {
                //refresh only the author dropdown list;
                Data.AllAutori()
                    .then(function (response) { 
                    vm.dataauts = {auts: response.data};
                    //alert(JSON.stringify(vm.datasubtips.subtips));
                })
            }); 
        }
  1. 其结果与以下图像相同:modal text entry pagemodal author entry page and hidden modal text entry page
© www.soinside.com 2019 - 2024. All rights reserved.