我不能完全肯定我知道你在问什么,但我会回答你的两个问题。
从对话框中获取数据
$mdDialog.show()
返回承诺。这意味着您可以使用
.then(...)
函数在承诺解析时处理其结果。通过调用
$mdDialog.hide()
(比如打电话
.cancel()
). 您可以将任何参数传递给
.hide()
.
例如:
$mdDialog
.show({
templateUrl: "test.html",
clickOutsideToClose: true,
openFrom: {top: -50, width: 30, height: 80},
closeTo: {left: 500},
targetEvent: ev,
scope: $scope,
preserveScope: true,
controller: function($scope) {
$scope.hide = function() {
var index = 1;
$mdDialog.hide(index);
};
$scope.cancel = function() {
$mdDialog.cancel();
};
}
})
.then(function(result) {
});
您甚至可以将表单中的值传递到
.隐藏()
.
将数据传递到对话框
$mdDialog允许您向控制器提供“本地”。与其他依赖项一样,局部变量被注入控制器函数。下面的示例演示了这一点。
$scope.open = function(index, ev, it) {
$scope.showText = true;
$mdDialog.show({
templateUrl: "test.html",
clickOutsideToClose: true,
openFrom: {top: -50, width: 30, height: 80},
closeTo: {left: 500},
locals: {
rowIndex: index
},
targetEvent: ev,
scope: $scope,
preserveScope: true,
controller: function($scope, rowIndex) {
$scope.row = $scope.tableRows[rowIndex];
$scope.cancel = function() {
$mdDialog.cancel();
};
}
});
};
其他变更
您还需要在tablerows中存储每个变量的属性。必须为表中的每个元素存储占位符和常用颜色。
plunkr的变化
here
反映所有这些想法。