$ mdDialog无法正常工作

时间:2016-09-10 14:04:31

标签: angularjs angular-material

$mdDialog无法使用自定义模板。 这是代码:

HTML:



<md-button class="md-icon-button" ng-click="commentPrompt($event)">
  <p>button
  </p>
</md-button>
&#13;
&#13;
&#13;

JS:

&#13;
&#13;
 var app = angular.module('BetaApp', ['ngMaterial', 'firebase']);
	
    
    app.controller('SideNavController', function($scope, $mdDialog) {
	$scope.commentPrompt = showDialog;
function showDialog($event){
		var parentEl = angular.element(document.body);
		$mdDialog.show({
         parent: parentEl,
         targetEvent: $event,
         templateUrl: 'comment.html',
         controller: DialogController
      });
	};
	function DialogController($scope, $mdDialog) {
        $scope.closeDialog = function() {
          $mdDialog.hide();
        }
    }
});
&#13;
&#13;
&#13;

COMMENT.HTML:

&#13;
&#13;
 <md-dialog>
<span>test
</span>
<md-button ng-click="closeDialog()" class="md-primary">
  <p>close</p>
  </md-button>
</md-dialog>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

更改此

md-button class="md-icon-button" ng-click="commentPrompt($event)">

md-button class="md-icon-button" ng-click="showDialog($event)">