0
votes

I use angular material and I would like to implement md-datepicker. I do something like here :

<md-input-container flex="100" layout="row">
    <div flex="45">
        <md-datepicker ng-model="$ctrl.myDate" placeholder="Enter date"></md-datepicker>
    </div>
</md-input-container>

Js looks like here:

var ctrl = this;
ctrl.myDate = new Date();

I have enter image description here Where I do mistake?

2

2 Answers

0
votes

Make sure you have loaded the correct libraries, and the version.

DEMO

angular.module('datepickerBasicUsage', ['ngMaterial'])
.controller('AppCtrl', function ($scope) {
  
});
<!doctype html>
<html ng-app="datepickerBasicUsage">
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-animate.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-aria.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.js"></script>
    <script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js"></script>
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.css">    
    <script src="app.js"></script>
  </head>
  <body>
  <div ng-controller="AppCtrl" style='padding: 40px;'>
   <md-content>
      <h4>Standard date-picker</h4>
      <md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>
    </md-content>
  </div>
  </body>
</html>
0
votes

Find problem, but don't know why it happens. When I replace

   <script type="text/javascript" src="../node_modules/angular-material/angular-material.js"></script>

to :

 <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.4/angular-material.js"></script>

Problem was gone, but I want local src so tried npm install, after remove folder with angular material, but it's not help