2017-02-05 35 views
0

我正在使用$mdDialog對話框,並希望在我的對話框模板中使用動態頭。 我想在彈出模板中發送數據。 這是我的對話框代碼。

$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模板使用的標題。

回答

0

你應該注入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); 
     }; 
    } 
+0

如何標題將HTML templateUrl使用: '設置/ dialog1.tmpl.html' – user3248761

+0

在HTML中的{{title}} –

+0

但標題被保留word for html可以使用不同的變量名稱 –

相關問題