1

I am using $mdDialog dialog and want dynamic header in my dialog template. I want to send data in popup template. This is my dialog code.

$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);
        });
    };

My dialog controller is

function DialogController($scope, $mdDialog) {

    $scope.Title = Title;
    $scope.hide = function () {
        $mdDialog.hide();
    };
    $scope.cancel = function () {
        $mdDialog.cancel();
    };
    $scope.answer = function (answer) {
        $mdDialog.hide(answer);
    };
}

Now i want to use Title in dialog1.tmpl.html template.

1 Answer 1

1

You should inject Title to your dialog's controller

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);
      };
    }
Sign up to request clarification or add additional context in comments.

4 Comments

how this Title will be used in html templateUrl: 'setting/dialog1.tmpl.html'
in html {{Title}}
But title is reserved word for html you may use different variable name
function DialogController($scope, $mdDialog) { $scope.ht = 'Add Employee'; $scope.hide = function () { $mdDialog.hide(); }; $scope.cancel = function () { $mdDialog.cancel(); }; $scope.answer = function (answer) { $mdDialog.hide(answer); }; }

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.