简体   繁体   English

如何在Mobile Angular Ui模态中将值传递给模态?

[英]How to pass value to modal in Mobile Angular Ui modal?

I am using Mobile Angular UI. 我正在使用Mobile Angular UI。 In parent window there is list of category names. 在父窗口中有类别名称列表。 I want selected category name should get updated from modal. 我希望所选类别名称应从模态更新。 I am able to display modal. 我能够显示模态。 I want to pass selected category item from parent view to modal. 我想将所选类别项目从父视图传递到模式。

My code in parent view 我在父视图中的代码

<div ng-controller="CategoryController as TitleCats">
<div ng-repeat="cats in TitleCats.categories">
<a href="" 
      ui-turn-on="titleCatUpdatemodal"
      class="btn btn-default" ng-click="TitleCats.openUpdateModel(cats)"> {{cats.name}}  --> Edit</a>
</div> 
<div ui-content-for="modals">
<div ng-include="'pages/titleCatUpdatemodal.html'"></div>
</div>
</div>

My Modal is 我的模态是

<div class="modal" ui-if='titleCatUpdatemodal' ui-state='titleCatUpdatemodal'>
<div class="modal-backdrop in"></div>
<div class="modal-dialog">
  <div class="modal-content">
   <div class="modal-header">
    <button class="close" 
            ui-turn-off="titleCatUpdatemodal">&times;</button>
    <h4 class="modal-title">Modal title</h4>
  </div>
  <div class="modal-body">

      <p><input type="text" ng-model="cats.name" >{{ cats.name }}</p>
  </div>
  <div class="modal-footer">
    <button ui-turn-off="titleCatUpdatemodal" class="btn btn-default">Close</button>
    <button ui-turn-off="titleCatUpdatemodal" class="btn btn-primary">Save changes</button>
  </div>
 </div>
</div>

When i click button it opens modal but no value! 当我单击按钮时,它会打开模态,但没有价值!

Anyone please let me know how to get value in modal. 任何人都请让我知道如何在情态中获得价值。 Thanks in advance. 提前致谢。

In your controller. 在您的控制器中。 you should have something similar to this: 您应该有类似以下内容:

    var modalInstance = $uibModal.open({
        animation: $scope.animationsEnabled,
        templateUrl: 'templates/myModal.html',
        controller: 'myModalCtrl',
        resolve: {
            myData: function () {
                //do stuff
                return stuff;
            }
        }
    });

Inside that resolve, you can fill out the function which should then be accessible in your modals controller 在该解决方案内部,您可以填写函数,然后应在模态控制器中访问该函数

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

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