栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Angular UI Modal 2 Way绑定不起作用

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Angular UI Modal 2 Way绑定不起作用

我认为您

ng-model="textbox.sample"
对父级和
ng-model="ngModel"
模态中的印象是相同的,因为您将传递
textbox.sample
给模态,并且能够在模态窗口中看到正确的值。起作用的唯一原因是因为
$scope.ngModel
每次打开模态窗口时都要显式设置属性。

使这项工作达到预期效果的一种方法是仅

$scope.textbox.sample
在两个地方都使用该属性,但我不建议这样做。

也许正确的方法是使用

modalInstance.result
诺言,如下所示:

在模态上创建一个按钮并使其

ng-click="ok()"

$scope.ok = function () {    $modalInstance.close($scope.ngModal); // will return this to the modalInstance.result}

然后在父控制器中,或通过任何方式打开模式窗口:

$scope.open = function (_ngModel) { // The ngModel is passed from open() function in template       var modalInstance = $modal.open({        templateUrl: 'ModalContent.html',        controller: ModalInstanceCtrl,         resolve: { ngModel: function () {     return _ngModel; }        } // end resolve    });    modalInstance.result.then(function (result) {        $scope.textbox.sample = result;    });};


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/649534.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号