cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="container" ng-app="modalTest" ng-controller="dialogTestCtrl">
  <div class="row">
    <div class="col-md-12">
      <h1>Dialog Custom Service with Date Picker Demo</h1>
      <p>Testing whether another directive in a custom dialog works properly.  In this demo we'll use the Date Picker directive that comes with Angular-UI-Bootstrap.</p>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <button class="btn btn-primary" ng-click="launch()">Launch Custom Dialog</button>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <br/>
      <p>Date Picked: <span class="text-info">{{data.dt | date:'fullDate' }}</span></p>
    </div>
  </div>
</div>
            
          
!
            
              angular.module('modalTest',['ui.bootstrap','dialogs.main'])

  .controller('dialogTestCtrl',function($scope,dialogs){
    //== Variables ==//
    $scope.data = {
      dt: new Date()
    };
    
    //== Methods ==//
    $scope.launch = function(){
      var dlg = dialogs.create('/dialogs/custom.html','customDialogCtrl',$scope.data);
      dlg.result.then(function(data){
        $scope.data = data;
      });
    }; // end launch
  }) // end dialogTest

  .controller('customDialogCtrl',function($log,$scope,$modalInstance,data){
    $scope.data = data;
    $scope.opened = false;
    
    //== Listeners ==//
    $scope.$watch('data.dt',function(val,old){
      $log.info('Date Changed: ' + val);
      $scope.opened = false;
    });
    
    //== Methods ==//
    $scope.setDate = function(){
      if(!angular.isDefined($scope.data.dt))
        $scope.data.dt = new Date(); // today
    };
    $scope.setDate();
    
    $scope.open = function($event){
      $event.preventDefault();
      $event.stopPropagation();
      $scope.opened = true;
    }; // end open
    
    $scope.done = function(){
      $modalInstance.close($scope.data);
    }; // end done
  }) // end customDialogCtrl

  .config(function(dialogsProvider){
    // this provider is only available in the 4.0.0+ versions of angular-dialog-service
    dialogsProvider.useBackdrop(true);
    dialogsProvider.useEscClose(true);
    dialogsProvider.useCopy(false);
    dialogsProvider.setSize('sm');
  }) // end config

  .run(function($templateCache){
    $templateCache.put('/dialogs/custom.html','<div class="modal-header"><h4 class="modal-title">Date Picker Test</h4></div><div class="modal-body"><p class="input-group"><input type="text" class="form-control" datepicker-popup="dd-MMMM-yyyy" ng-model="data.dt" datepicker-mode="year" is-open="opened" show-button-bar="false" /><span class="input-group-btn"><button class="btn btn-default" ng-click="open($event)"><span class="glyphicon glyphicon-calendar"></span></button></span></p></div><div class="modal-footer"><button class="btn btn-default" ng-click="done()">Done</button></div>');
  }); // end run
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console