在 $mdDialog 中传递数据并在 html 模板中使用
Passing data in $mdDialog and use in html template
我正在使用 $mdDialog
对话框并希望在我的对话框模板中使用动态 header。
我想在弹出模板中发送数据。
这是我的对话代码。
$scope.showAdvanced = function (ev, Title) {
$rootScope.tt = Title;
var useFullScreen = ($mdMedia('sm') || $mdMedia('xs')) && $scope.customFullscreen;
$mdDialog.show({
controller: DialogController,
templateUrl: 'setting/dialog1.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: useFullScreen,
locals: { Title: Title },
})
.then(function (answer) {
$scope.status = 'You said the information was "' + answer + '".';
}, function () {
$scope.status = 'You cancelled the dialog.';
});
$scope.$watch(function () {
return $mdMedia('xs') || $mdMedia('sm');
}, function (wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
我的对话框控制器是
function DialogController($scope, $mdDialog) {
$scope.Title = Title;
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}
现在我想在 dialog1.tmpl.html
模板中使用标题。
您应该将 Title
注入对话框的控制器
function DialogController($scope, $mdDialog, Title) {
$scope.Title = Title;
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}
我正在使用 $mdDialog
对话框并希望在我的对话框模板中使用动态 header。
我想在弹出模板中发送数据。
这是我的对话代码。
$scope.showAdvanced = function (ev, Title) {
$rootScope.tt = Title;
var useFullScreen = ($mdMedia('sm') || $mdMedia('xs')) && $scope.customFullscreen;
$mdDialog.show({
controller: DialogController,
templateUrl: 'setting/dialog1.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: useFullScreen,
locals: { Title: Title },
})
.then(function (answer) {
$scope.status = 'You said the information was "' + answer + '".';
}, function () {
$scope.status = 'You cancelled the dialog.';
});
$scope.$watch(function () {
return $mdMedia('xs') || $mdMedia('sm');
}, function (wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
我的对话框控制器是
function DialogController($scope, $mdDialog) {
$scope.Title = Title;
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}
现在我想在 dialog1.tmpl.html
模板中使用标题。
您应该将 Title
注入对话框的控制器
function DialogController($scope, $mdDialog, Title) {
$scope.Title = Title;
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}