2016-10-07 7 views
0

보고 있어요 :나는 각도 재료 예를 들어 대화 상자를 실행하려고하지만이 데모를 실행하려면 빈 페이지

https://material.angularjs.org/latest/demo/dialog

을하지만 브라우저에서이 프로그램을 실행할 때 빈 페이지가

<html lang="en" > 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <!-- Angular Material style sheet --> 
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css"> 
    <style> 
    .dialogdemoBasicUsage #popupContainer { 
    position: relative; } 

    .dialogdemoBasicUsage .footer { 
    width: 100%; 
    text-align: center; 
    margin-left: 20px; } 

    .dialogdemoBasicUsage .footer, .dialogdemoBasicUsage .footer > code { 
    font-size: 0.8em; 
    margin-top: 50px; } 

    .dialogdemoBasicUsage button { 
    width: 200px; } 

    .dialogdemoBasicUsage div#status { 
    color: #c60008; } 

    .dialogdemoBasicUsage .dialog-demo-prerendered md-checkbox { 
    margin-bottom: 0; } 
    </style> 

    <!-- 
    Your HTML content here 
    --> 

    <!-- Angular Material requires Angular.js Libraries --> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-resource.min.js"></script> 




    <!-- Your application bootstrap --> 
    <script type="text/javascript">  
    /** 
    * You must include the dependency on 'ngMaterial' 
    */ 
     angular.module('dialogDemo1', ['ngMaterial']).controller('AppCtrl', function($scope, $mdDialog) { 
     $scope.status = ' '; 
     $scope.customFullscreen = false; 

     $scope.showAlert = function(ev) { 
     // Appending dialog to document.body to cover sidenav in docs app 
     // Modal dialogs should fully cover application 
     // to prevent interaction outside of dialog 
     $mdDialog.show(
      $mdDialog.alert() 
      .parent(angular.element(document.querySelector('#popupContainer'))) 
      .clickOutsideToClose(true) 
      .title('This is an alert title') 
      .textContent('You can specify some description text in here.') 
      .ariaLabel('Alert Dialog Demo') 
      .ok('Got it!') 
      .targetEvent(ev) 
     ); 
     }; 

     $scope.showConfirm = function(ev) { 
     // Appending dialog to document.body to cover sidenav in docs app 
     var confirm = $mdDialog.confirm() 
       .title('Would you like to delete your debt?') 
       .textContent('All of the banks have agreed to forgive you your debts.') 
       .ariaLabel('Lucky day') 
       .targetEvent(ev) 
       .ok('Please do it!') 
       .cancel('Sounds like a scam'); 

     $mdDialog.show(confirm).then(function() { 
      $scope.status = 'You decided to get rid of your debt.'; 
     }, function() { 
      $scope.status = 'You decided to keep your debt.'; 
     }); 
     }; 

     $scope.showPrompt = function(ev) { 
     // Appending dialog to document.body to cover sidenav in docs app 
     var confirm = $mdDialog.prompt() 
      .title('What would you name your dog?') 
      .textContent('Bowser is a common name.') 
      .placeholder('Dog name') 
      .ariaLabel('Dog name') 
      .initialValue('Buddy') 
      .targetEvent(ev) 
      .ok('Okay!') 
      .cancel('I\'m a cat person'); 

     $mdDialog.show(confirm).then(function(result) { 
      $scope.status = 'You decided to name your dog ' + result + '.'; 
     }, function() { 
      $scope.status = 'You didn\'t name your dog.'; 
     }); 
     }; 

     $scope.showAdvanced = function(ev) { 
     $mdDialog.show({ 
      controller: DialogController, 
      templateUrl: 'dialog1.tmpl.html', 
      parent: angular.element(document.body), 
      targetEvent: ev, 
      clickOutsideToClose:true, 
      fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints. 
     }) 
     .then(function(answer) { 
      $scope.status = 'You said the information was "' + answer + '".'; 
     }, function() { 
      $scope.status = 'You cancelled the dialog.'; 
     }); 
     }; 

     $scope.showTabDialog = function(ev) { 
     $mdDialog.show({ 
      controller: DialogController, 
      templateUrl: 'tabDialog.tmpl.html', 
      parent: angular.element(document.body), 
      targetEvent: ev, 
      clickOutsideToClose:true 
     }) 
      .then(function(answer) { 
       $scope.status = 'You said the information was "' + answer + '".'; 
      }, function() { 
       $scope.status = 'You cancelled the dialog.'; 
      }); 
     }; 

     $scope.showPrerenderedDialog = function(ev) { 
     $mdDialog.show({ 
      controller: DialogController, 
      contentElement: '#myDialog', 
      parent: angular.element(document.body), 
      targetEvent: ev, 
      clickOutsideToClose: true 
     }); 
     }; 

     function DialogController($scope, $mdDialog) { 
     $scope.hide = function() { 
      $mdDialog.hide(); 
     }; 

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

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

    </script> 
    </head> 

<body> 

<div ng-controller="AppCtrl" class="md-padding" id="popupContainer" ng-cloak> 
    <p class="inset"> 
    Open a dialog over the app's content. Press escape or click outside to close the dialog and 
    send focus back to the triggering button. 
    </p> 

    <div class="dialog-demo-content" layout="row" layout-wrap layout-margin layout-align="center"> 
    <md-button class="md-primary md-raised" ng-click="showAlert($event)" > 
     Alert Dialog 
    </md-button> 
    <md-button class="md-primary md-raised" ng-click="showConfirm($event)" > 
     Confirm Dialog 
    </md-button> 
    <md-button class="md-primary md-raised" ng-click="showPrompt($event)" > 
     Prompt Dialog 
    </md-button> 
    <md-button class="md-primary md-raised" ng-click="showAdvanced($event)"> 
     Custom Dialog 
    </md-button> 
    <md-button class="md-primary md-raised" ng-click="showTabDialog($event)" > 
     Tab Dialog 
    </md-button> 
    <md-button class="md-primary md-raised" ng-if="listPrerenderedButton" ng-click="showPrerenderedDialog($event)"> 
     Pre-Rendered Dialog 
    </md-button> 
    </div> 
    <p class="footer">Note: The <b>Confirm</b> dialog does not use <code>$mdDialog.clickOutsideToClose(true)</code>.</p> 

    <div ng-if="status" id="status"> 
    <b layout="row" layout-align="center center" class="md-padding"> 
     {{status}} 
    </b> 
    </div> 

    <div class="dialog-demo-prerendered"> 
    <md-checkbox ng-model="listPrerenderedButton">Show Pre-Rendered Dialog</md-checkbox> 
    <p class="md-caption">Sometimes you may not want to compile the dialogs template on each opening.</p> 
    <md-checkbox ng-model="customFullscreen" aria-label="Fullscreen custom dialog">Use full screen mode for custom dialog</md-checkbox> 
    <p class="md-caption">Allows the dialog to consume all available space on small devices</p> 
    </div> 

    <div style="visibility: hidden"> 
    <div class="md-dialog-container" id="myDialog"> 
     <md-dialog layout-padding> 
     <h2>Pre-Rendered Dialog</h2> 
     <p> 
      This is a pre-rendered dialog, which means that <code>$mdDialog</code> doesn't compile its 
      template on each opening. 
      <br/><br/> 
      The Dialog Element is a static element in the DOM, which is just visually hidden.<br/> 
      Once the dialog opens, we just fetch the element from the DOM into our dialog and upon close 
      we restore the element back into its old DOM position. 
     </p> 
     </md-dialog> 
    </div> 
    </div> 

</div> 


</body> 
</html> 

문제가 무엇인지 아는 사람이 있습니까?

+0

CDN 포함 된 각 재료를

을 부트 스트랩 포함, 당신은 그 확인 귀하의 애플 리케이션은 잘 작동 – byteC0de

+0

@ hkguile 내 대답을 볼 기회가있어? 관련된 모든 질문을 할 수 있습니다. :) –

답변

0

다음은 작동 코드입니다. 내가 만든 한 두 변경

몸에 ng-app 태그

<html lang="en" > 
 
<head> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <!-- Angular Material style sheet --> 
 
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css"> 
 
    <style> 
 
     .dialogdemoBasicUsage #popupContainer { 
 
      position: relative; } 
 

 
     .dialogdemoBasicUsage .footer { 
 
      width: 100%; 
 
      text-align: center; 
 
      margin-left: 20px; } 
 

 
     .dialogdemoBasicUsage .footer, .dialogdemoBasicUsage .footer > code { 
 
      font-size: 0.8em; 
 
      margin-top: 50px; } 
 

 
     .dialogdemoBasicUsage button { 
 
      width: 200px; } 
 

 
     .dialogdemoBasicUsage div#status { 
 
      color: #c60008; } 
 

 
     .dialogdemoBasicUsage .dialog-demo-prerendered md-checkbox { 
 
      margin-bottom: 0; } 
 
    </style> 
 

 
    <!-- 
 
     Your HTML content here 
 
    --> 
 

 
    <!-- Angular Material requires Angular.js Libraries --> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script> 
 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-resource.min.js"></script> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.js"></script> 
 

 

 

 

 
    <!-- Your application bootstrap --> 
 
</head> 
 

 
<body ng-app="dialogDemo"> 
 

 
<div ng-controller="AppCtrl" class="md-padding" id="popupContainer" ng-cloak> 
 
    <p class="inset"> 
 
     Open a dialog over the app's content. Press escape or click outside to close the dialog and 
 
     send focus back to the triggering button. 
 
    </p> 
 

 
    <div class="dialog-demo-content" layout="row" layout-wrap layout-margin layout-align="center"> 
 
     <md-button class="md-primary md-raised" ng-click="showAlert($event)" > 
 
      Alert Dialog 
 
     </md-button> 
 
     <md-button class="md-primary md-raised" ng-click="showConfirm($event)" > 
 
      Confirm Dialog 
 
     </md-button> 
 
     <md-button class="md-primary md-raised" ng-click="showPrompt($event)" > 
 
      Prompt Dialog 
 
     </md-button> 
 
     <md-button class="md-primary md-raised" ng-click="showAdvanced($event)"> 
 
      Custom Dialog 
 
     </md-button> 
 
     <md-button class="md-primary md-raised" ng-click="showTabDialog($event)" > 
 
      Tab Dialog 
 
     </md-button> 
 
     <md-button class="md-primary md-raised" ng-if="listPrerenderedButton" ng-click="showPrerenderedDialog($event)"> 
 
      Pre-Rendered Dialog 
 
     </md-button> 
 
    </div> 
 
    <p class="footer">Note: The <b>Confirm</b> dialog does not use <code>$mdDialog.clickOutsideToClose(true)</code>.</p> 
 

 
    <div ng-if="status" id="status"> 
 
     <b layout="row" layout-align="center center" class="md-padding"> 
 
      {{status}} 
 
     </b> 
 
    </div> 
 

 
    <div class="dialog-demo-prerendered"> 
 
     <md-checkbox ng-model="listPrerenderedButton">Show Pre-Rendered Dialog</md-checkbox> 
 
     <p class="md-caption">Sometimes you may not want to compile the dialogs template on each opening.</p> 
 
     <md-checkbox ng-model="customFullscreen" aria-label="Fullscreen custom dialog">Use full screen mode for custom dialog</md-checkbox> 
 
     <p class="md-caption">Allows the dialog to consume all available space on small devices</p> 
 
    </div> 
 

 
    <div style="visibility: hidden"> 
 
     <div class="md-dialog-container" id="myDialog"> 
 
      <md-dialog layout-padding> 
 
       <h2>Pre-Rendered Dialog</h2> 
 
       <p> 
 
        This is a pre-rendered dialog, which means that <code>$mdDialog</code> doesn't compile its 
 
        template on each opening. 
 
        <br/><br/> 
 
        The Dialog Element is a static element in the DOM, which is just visually hidden.<br/> 
 
        Once the dialog opens, we just fetch the element from the DOM into our dialog and upon close 
 
        we restore the element back into its old DOM position. 
 
       </p> 
 
      </md-dialog> 
 
     </div> 
 
    </div> 
 

 
</div> 
 

 

 
</body> 
 
<script type="text/javascript"> 
 
    /** 
 
    * You must include the dependency on 'ngMaterial' 
 
    */ 
 
    angular.module('dialogDemo', ['ngMaterial']).controller('AppCtrl', function($scope, $mdDialog) { 
 
     $scope.status = ' '; 
 
     $scope.customFullscreen = false; 
 

 
     $scope.showAlert = function(ev) { 
 
      // Appending dialog to document.body to cover sidenav in docs app 
 
      // Modal dialogs should fully cover application 
 
      // to prevent interaction outside of dialog 
 
      $mdDialog.show(
 
        $mdDialog.alert() 
 
          .parent(angular.element(document.querySelector('#popupContainer'))) 
 
          .clickOutsideToClose(true) 
 
          .title('This is an alert title') 
 
          .textContent('You can specify some description text in here.') 
 
          .ariaLabel('Alert Dialog Demo') 
 
          .ok('Got it!') 
 
          .targetEvent(ev) 
 
      ); 
 
     }; 
 

 
     $scope.showConfirm = function(ev) { 
 
      // Appending dialog to document.body to cover sidenav in docs app 
 
      var confirm = $mdDialog.confirm() 
 
        .title('Would you like to delete your debt?') 
 
        .textContent('All of the banks have agreed to forgive you your debts.') 
 
        .ariaLabel('Lucky day') 
 
        .targetEvent(ev) 
 
        .ok('Please do it!') 
 
        .cancel('Sounds like a scam'); 
 

 
      $mdDialog.show(confirm).then(function() { 
 
       $scope.status = 'You decided to get rid of your debt.'; 
 
      }, function() { 
 
       $scope.status = 'You decided to keep your debt.'; 
 
      }); 
 
     }; 
 

 
     $scope.showPrompt = function(ev) { 
 
      // Appending dialog to document.body to cover sidenav in docs app 
 
      var confirm = $mdDialog.prompt() 
 
        .title('What would you name your dog?') 
 
        .textContent('Bowser is a common name.') 
 
        .placeholder('Dog name') 
 
        .ariaLabel('Dog name') 
 
        .initialValue('Buddy') 
 
        .targetEvent(ev) 
 
        .ok('Okay!') 
 
        .cancel('I\'m a cat person'); 
 

 
      $mdDialog.show(confirm).then(function(result) { 
 
       $scope.status = 'You decided to name your dog ' + result + '.'; 
 
      }, function() { 
 
       $scope.status = 'You didn\'t name your dog.'; 
 
      }); 
 
     }; 
 

 
     $scope.showAdvanced = function(ev) { 
 
      $mdDialog.show({ 
 
         controller: DialogController, 
 
         templateUrl: 'dialog1.tmpl.html', 
 
         parent: angular.element(document.body), 
 
         targetEvent: ev, 
 
         clickOutsideToClose:true, 
 
         fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints. 
 
        }) 
 
        .then(function(answer) { 
 
         $scope.status = 'You said the information was "' + answer + '".'; 
 
        }, function() { 
 
         $scope.status = 'You cancelled the dialog.'; 
 
        }); 
 
     }; 
 

 
     $scope.showTabDialog = function(ev) { 
 
      $mdDialog.show({ 
 
         controller: DialogController, 
 
         templateUrl: 'tabDialog.tmpl.html', 
 
         parent: angular.element(document.body), 
 
         targetEvent: ev, 
 
         clickOutsideToClose:true 
 
        }) 
 
        .then(function(answer) { 
 
         $scope.status = 'You said the information was "' + answer + '".'; 
 
        }, function() { 
 
         $scope.status = 'You cancelled the dialog.'; 
 
        }); 
 
     }; 
 

 
     $scope.showPrerenderedDialog = function(ev) { 
 
      $mdDialog.show({ 
 
       controller: DialogController, 
 
       contentElement: '#myDialog', 
 
       parent: angular.element(document.body), 
 
       targetEvent: ev, 
 
       clickOutsideToClose: true 
 
      }); 
 
     }; 
 

 
     function DialogController($scope, $mdDialog) { 
 
      $scope.hide = function() { 
 
       $mdDialog.hide(); 
 
      }; 
 

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

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

 
</script> 
 
</html>

+0

나는 같은 문제가 있었고 몸에 ng-app를 두는 것은 내가 누락 된 것이었다. body 태그 안의 div에 ng-app를 설정할 수없는 이유는 무엇입니까? – Eric