Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en" ng-app="StarterApp">
  <head>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.0-rc4/angular-material.css">
  </head>
  <body layout="column" ng-controller="AppCtrl">
    <md-content id="content" flex>
      
       <div class="calc" md-whiteframe="3">
         <div class="display" layout='column' layout-padding >
           <!-- TOP BAR-->
           <div class="up" flex layout='row' layout-padding layout-align='end center'>
             <div class="md-display-1" ng-repeat="x in stuff track by $index">
               {{x}}
             </div>
           </div>
          <!-- <div class="up" flex layout='row' layout-padding layout-align='end center'>
             <div class="md-display-1">
               {{stuff}}
             </div>
           </div> -->
         </div>
         <!-- CONTROLS-->
         <div class="controls" layout='row' layout-wrap>
           <div flex="75">
              <md-grid-list md-cols='3' md-row-height='1:1' md-gutter='0px'>
               <md-grid-tile class="number" ng-repeat='i in [9,8,7,6,5,4,3,2,1,".",0,"00"]'><md-button flex ng-click='acceptInput(i)'><span class="big">{{i}}</span></md-button></md-grid-tile>
             </md-grid-list>
           </div>
           <div flex="25">
             <md-grid-list md-cols='1' md-row-height='6:4' md-gutter='0px'>
               <md-grid-tile class="control"><md-button flex ng-click='clearCalc()'>CLR</md-button></md-grid-tile>
               <md-grid-tile class="control"><md-button flex ng-click='acceptInput("/")'>/</md-button></md-grid-tile>
               <md-grid-tile class="control"><md-button flex ng-click='acceptInput("*")'>X</md-button></md-grid-tile>
               <md-grid-tile class="control"><md-button flex ng-click='acceptInput("-")'>-</md-button></md-grid-tile>
               <md-grid-tile class="control"><md-button flex ng-click='acceptInput("+")'>+</md-button></md-grid-tile>
               <md-grid-tile class="control"><md-button flex ng-click='doMath()'>=</md-button></md-grid-tile>
             </md-grid-list>
           </div>
         </div>
       </div>
    </md-content>
    <a target="_blank" href="https://www.instagram.com/michaelmartire/"><div class="white">Made by @MichaelMartire</div></a>
    <!-- Angular Material Dependencies -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.js"></script>
    <!-- Angular Material -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.0-rc4/angular-material.min.js"></script>
  </body>
</html>
              
            
!

CSS

              
                
// base
#content{
  background-color: #8EC1BC;
  height: 100%;
}

.header{
  background-color: transparent !important;}

.calc{
  width: 600px;
  margin: 0 auto;
  margin-top: 100px;}

  .display{
    background: #f5f5f5;
    color: #795548;}

    .up, .bottom{
      height: 80px;}

  .controls,
    .number{
      background-color: #8D6E63;}
    .control{
      background-color: #4DB6AC;}

    .number, .control
      button{
        padding: 0px;
        margin: 0;
        font-size: 32px;
        color: #fff;
        //height: 100%;
}

.big {
  font-size: 32px;
}

.white{
  position: fixed;
  color: #4DB6AC;
  background-color:#fff;
  padding:7px;
  top: 0px;
  left:0px;
}




// Colors
$gray: #eee;

// Angular
/**[ng-click] {
  &:hover {
    cursor: pointer;
  }
} **/

// Main content bg color
// md-content.md-default-theme {
  // background-color: $gray;
// }


// Round avatar
.md-avatar {
  & > svg {
    border-radius: 50%;
  }
}

/* fade animation */
.animate-show {
    transition: 0.75s ease-out opacity;
    opacity: 1;
  &.ng-hide {
    height: 0;
    min-height: 0;
    opacity: 0;
    overflow: hidden;
  }
}
              
            
!

JS

              
                var app = angular.module('StarterApp', ['ngMaterial']);

app.controller('AppCtrl', ['$scope', function($scope){
  
  $scope.calcInput = '0';
  $scope.answer = "";
  $scope.memory = 0;
  $scope.stuff = [0];
  $scope.justGotMath = false;
   $scope.acceptInput = function(n) {
    var last;
    if ($scope.justGotMath) {
      $scope.justGotMath = false;
      if (!$scope.isOperator(n)) {
        $scope.stuff = [];
      }
    }
    n = n.toString();
    if (n === '.') {
      last = $scope.stuff.pop();
      if ($scope.isOperator(last) || Math.ceil(last) !== parseInt(last)) {
        $scope.stuff.push(last);
      } else {
        last += '.';
        $scope.stuff.push(last);
        $scope.writeScreen();
      }
      return;
    }
    if ($scope.isOperator(n)) {
      if (!$scope.stuff.length) {
        return;
      }
      last = $scope.stuff.pop();
      if (!$scope.isOperator(last)) {
        $scope.stuff.push(last);
      }
      $scope.stuff.push(n);
    } else if ($scope.stuff.length) {
      last = $scope.stuff.pop();
      if ($scope.isOperator(last)) {
        $scope.stuff.push(last);
        $scope.stuff.push(n);
      } else if (last.toString() === '0') {
        $scope.stuff.push(n);
      } else {
        last += n.toString();
        $scope.stuff.push(last);
      }
    } else {
      $scope.stuff.push(n);
    }
    $scope.writeScreen();
    console.log($scope.stuff);
    return this;
  };
  
  $scope.isOperator = function(n) {
    if (isNaN(n)) {
      if (n !== '.') {
        return true;
      }
    }
    return false;
  };
  
  
  $scope.writeScreen = function() {
    var write;
    write = '';
    $.each($scope.stuff, function(i, k) {
      if (write === '') {
        return write = k;
      } else {
        return write += k.toString();
      }
    });
    if (write === '') {
      write = '0';
    }
    $scope.calcInput = write.toString();
    return;
    if ($scope.isOperator(n)) {
      write = n === '/' ? '&divide;' : n === '*' ? '&times;' : n === '+' ? '&plus;' : n === '-' ? '&minus;' : void 0;
    }
    if (!$scope.stuff.length) {
      $scope.calcInput = write;
    } else {
      $scope.calcInput += write.toString();
    }
    return this;
  };
 
  $scope.clearCalc = function() {
    $scope.stuff = [];
    return $scope.writeScreen();
  };
  
  $scope.doMath = function() {
    $scope.justGotMath = true;
    $scope.stuff = [$scope.getMath()];
    return $scope.writeScreen();
  };
  $scope.getMath = function() {
    var job, last, x;
    last = $scope.stuff.pop();
    if (!$scope.isOperator(last)) {
      $scope.stuff.push(last);
    }
    job = $scope.stuff.join('');
    x = 0;
    eval('x = ' + job + ';');
    return x;
  };

}]);

















app.controller('ListBottomSheetCtrl', function($scope, $mdBottomSheet) {
  $scope.items = [
    { name: 'Share', icon: 'social:ic_share_24px' },
    { name: 'Upload', icon: 'file:ic_cloud_upload_24px' },
    { name: 'Copy', icon: 'content:ic_content_copy_24px' },
    { name: 'Print this page', icon: 'action:ic_print_24px' },
  ];
  
  $scope.listItemClick = function($index) {
    var clickedItem = $scope.items[$index];
    $mdBottomSheet.hide(clickedItem);
  };
});


app.controller('DemoCtrl', DemoCtrl);
  function DemoCtrl ($timeout, $q) {
    var self = this;
    // list of `state` value/display objects
    self.states        = loadAll();
    self.selectedItem  = null;
    self.searchText    = null;
    self.querySearch   = querySearch;
    // ******************************
    // Internal methods
    // ******************************
    /**
     * Search for states... use $timeout to simulate
     * remote dataservice call.
     */
    function querySearch (query) {
      var results = query ? self.states.filter( createFilterFor(query) ) : [];
      return results;
    }
    /**
     * Build `states` list of key/value pairs
     */
    function loadAll() {
      var allStates = 'Ali Conners, Alex, Scott, Jennifer, \
              Sandra Adams, Brian Holt, \
              Trevor Hansen';
      return allStates.split(/, +/g).map( function (state) {
        return {
          value: state.toLowerCase(),
          display: state
        };
      });
    }
    /**
     * Create filter function for a query string
     */
    function createFilterFor(query) {
      var lowercaseQuery = angular.lowercase(query);
      return function filterFn(state) {
        return (state.value.indexOf(lowercaseQuery) === 0);
      };
    }
  };

app.config(function($mdThemingProvider) {
  var customBlueMap = 		$mdThemingProvider.extendPalette('light-blue', {
    'contrastDefaultColor': 'light',
    'contrastDarkColors': ['50'],
    '50': 'ffffff'
  });
  $mdThemingProvider.definePalette('customBlue', customBlueMap);
  $mdThemingProvider.theme('brown')
    .primaryPalette('customBlue', {
      'default': '500',
      'hue-1': '50'
    })
    .accentPalette('teal');
  $mdThemingProvider.theme('input', 'default')
        .primaryPalette('grey')
});

app.config(function($mdIconProvider) {
    $mdIconProvider
      // linking to https://github.com/google/material-design-icons/tree/master/sprites/svg-sprite
      // 
      .iconSet('action', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-action.svg', 24)
      .iconSet('alert', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-alert.svg', 24)
      .iconSet('av', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-av.svg', 24)
      .iconSet('communication', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-communication.svg', 24)
      .iconSet('content', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-content.svg', 24)
      .iconSet('device', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-device.svg', 24)
      .iconSet('editor', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-editor.svg', 24)
      .iconSet('file', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-file.svg', 24)
      .iconSet('hardware', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-hardware.svg', 24)
      .iconSet('image', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-image.svg', 24)
      .iconSet('maps', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-maps.svg', 24)
      .iconSet('navigation', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-navigation.svg', 24)
      .iconSet('notification', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-notification.svg', 24)
      .iconSet('social', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-social.svg', 24)
      .iconSet('toggle', 'https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-toggle.svg', 24)
    
      // Illustrated user icons used in the docs https://material.angularjs.org/latest/#/demo/material.components.gridList
      .iconSet('avatars', 'https://raw.githubusercontent.com/angular/material/master/docs/app/icons/avatar-icons.svg', 24)
      .defaultIconSet('https://raw.githubusercontent.com/google/material-design-icons/master/sprites/svg-sprite/svg-sprite-action.svg', 24);
});

              
            
!
999px

Console