Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material Datepicker is empty

I am currently building a web application with Angular and I am using Angular Material for some UI components. Currently, I have an issue that I can't resolve. When I use the datepicker like described on https://material.angularjs.org/latest/demo/datepicker, the window opens but it stays empty. enter image description here

Here's the code snippet for the datepicker.

<md-datepicker ng-model="vm.registrationData.birthDate"
                                   md-placeholder="{{'start_register_birth_date' | translate}}"
                                   required></md-datepicker>
                    <div class="error-message"
                         ng-messages="registerForm.birthDate.$error"
                         ng-if="registerForm.birthDate.$touched && registerForm.birthDate.$invalid">
                        <div class="arrow-right"></div>
                        <p ng-message="required">{{'start_register_error_birthDate_required' | translate}}</p>
                    </div>

Is there maybe something wrong with my imports?

<!-- bower:js -->
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-messages/angular-messages.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-translate/angular-translate.js"></script>
<script src="bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-aria/angular-aria.js"></script>
<script src="bower_components/angular-material/angular-material.js"></script>
<script src="bower_components/moment/moment.js"></script>
<!-- endbower -->
<script src="js/app.min.js"></script>
<script src="js/config.min.js"></script>

<!-- bower:css -->
<link rel="stylesheet" href="bower_components/angular-material/angular-material.css" />
<!-- endbower -->
<link rel="stylesheet" type="text/css" href="css/styles.css" />
like image 384
BigKahuna Avatar asked Dec 24 '16 22:12

BigKahuna


1 Answers

Use an older version of Angular, say 1.5.9. Angular 1.6 disables prebinding of controllers.

See Issue #10168 for more details. You can add

angular.module('myApp', [])
  .config(function($compileProvider) {
    $compileProvider.preAssignBindingsEnabled(true);
  });

if you insist on using Angular 1.6.

like image 181
ppham27 Avatar answered Sep 21 '22 20:09

ppham27