【发布时间】:2015-09-23 07:12:25
【问题描述】:
主列表页面有编辑按钮。这将打开已编辑行的详细信息。
Way-1: 现在,如果我设置“ctrl.parent.q_details.client_location”,它将与父列表控制器绑定,并且它作为 2-way绑定并自动更改编辑框中的值更改,这不是这里的要求。
这里只是我想在输入框中显示并允许编辑值。不想在父控制器中更改。
► 以下是父控制器中调用 mdDialog 的代码
$mdDialog.show({
locals:{parent: $scope},
clickOutsideToClose: true,
controllerAs: 'ctrl',
templateUrl: 'quotation/edit/',//+edit_id,
controller: function () { this.parent = $scope; },
});
► 以下是弹出 mdDialog 的代码。
<md-dialog aria-label="">
<div ng-app="inputBasicDemo" ng-controller="deliverController" layout="column">
<form name="" class="internal_note_cont">
<md-content class="md-padding">
<md-input-container class="md-input-has-value" flex>
<label>Client Name</label>
<input ng-model="qe.client_name" required >
</md-input-container>
<md-input-container flex>
<label>Client Location</label>
<input required ng-model="ctrl.parent.q_details.client_location">
</md-input-container>
</md-content>
</form>
<div>
</div>
</div>
<input type="" required ng-model="ctrl.parent.q_details.recid">
</md-dialog>
方式 2: 第二种方式是直接从 DB 发送值,而不绑定到 Dialog 控制器 (deliverController) 的 ng-model。
]).controller("deliverController", ["$scope", "$filter","$http","$route","$window","$mdDialog",
function ($scope, $filter,$http,$route,$window,$mdDialog) {
$scope.qe.client_name = '12345'; // just to test.
}
这给出了 undefine $scope.qe 的错误。
所以最终,我无法将数据发送到 mdDialogue 并显示它们并允许以正常方式对其进行编辑。
请任何有经验的有角的人帮助我。我是角度的新手。
2 天以来,我一直在尝试不同的方式。
【问题讨论】:
-
您可以使用 ng-bind 设置一次性绑定。您还可以通过服务在父子之间传递数据。
-
你试过
preserveScope: true吗?
标签: javascript angularjs modal-dialog material-design angular-material