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

              
                <div ng-controller="DemoCtrl as ctrl" layout="column" ng-cloak="" class="autocompletedemoBasicUsage" ng-app="MyApp">
  <md-content class="md-padding">
    <form ng-submit="$event.preventDefault()">
      <p>Select first item to populate second dropdown</p>
      <md-autocomplete  md-selected-item="ctrl.selectedItem"  md-selected-item-change="ctrl.selectedItemChange(item.id)" md-items="item in ctrl.country" md-item-text="item.name" md-min-length="0" placeholder="What is your favorite US country?">
        <md-item-template>
          <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.name}}</span>
        </md-item-template>
        <md-not-found>
          No states matching "{{ctrl.searchText}}" were found.
        </md-not-found>
      </md-autocomplete>
      <br/>

 <br/>
  <md-autocomplete  md-selected-item="ctrl.selectedStateItem"  md-selected-item-change="ctrl.selectedItemChange(item.id)" md-items="item in ctrl.states" md-item-text="item.name" md-min-length="0" placeholder="What is your favorite US state?">
        <md-item-template>
          <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.name}}</span>
        </md-item-template>
        <md-not-found>
          No states matching "{{ctrl.searchText}}" were found.
       
        </md-not-found>
      </md-autocomplete>
    </form>
  </md-content>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                (function () {
  'use strict';
  angular
      .module('MyApp',['ngMaterial', 'ngMessages', 'material.svgAssetsCache'])
      .controller('DemoCtrl', DemoCtrl);

  function DemoCtrl ($timeout, $q, $log) {
    var self = this;


    // list of `state` value/display objects
    self.country        = loadAll();

    self.selectedItemChange = selectedItemChange;

    function selectedItemChange(item) {
      var data = [{id:1,countryId:1,name:"karnataka"},{id:2,countryId:2,name:"Tamilnadu"}]
      if(item == data[0].countryId){
        self.states  = data;
      }
    }

    /**
     * Build `states` list of key/value pairs
     */
    function loadAll() {
      var allStates = [{id:1,name:'Alabama'},{id:2,name:'Alaska'},{id:3,name:'Arizona'},{id:4,name:'Arkansas'}]

      return allStates
    }


  }
})();


/**
Copyright 2016 Google Inc. All Rights Reserved. 
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at https://material.angularjs.org/license.
**/
              
            
!
999px

Console