角度材料日期选择器与空白日历

时间:2016-12-15 18:06:29

标签: angularjs angular-material

我在角度材料版本1.1.1中使用日期选择器时遇到了一些麻烦,如果我更改为角度材料1.1.0日历可以工作,就像我在编写代码时那样:http://codepen.io/lhrossi/pen/eBQLoy

这是我的HTML:

<md-content md-theme="infocargas" layout-padding>
    <form name="newDeliveryForm">
        <div layout-gt-xs="row">
            <md-input-container class="md-block" flex-gt-xs>
                <label>Operador Logístico (Bloqueado)</label>
                <input ng-model="company" disabled /> 
            </md-input-container>
        </div>

        <div layout-gt-sm="row">

            <md-input-container flex-gt-sm>
                <label>Digite CTe</label>
                <input ng-model="delivery.cte" />
            </md-input-container>

        </div>

        <div layout-gt-sm="row">

            <md-input-container flex-gt-sm>
                <label>Entrega Para</label>
                <!--<md-datepicker ng-model="myDate"></md-datepicker>-->
                <md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>

            </md-input-container>

        </div>
        <md-button class="md-raised md-primary">Gerar Código</md-button>

    </form>

</md-content>

这是一个错误,还是有其他想法呢?我害怕改变材料版本,以免破坏系统上的其他东西。

我感谢任何帮助。

1 个答案:

答案 0 :(得分:5)

Angular 1.6在编译器上引入了一些破坏datepicker功能的优化(它们在Angular更改日志中被列为重大更改)。

虽然Angular Material团队没有发布新的补丁版本(可能在一两年内......)但它不起作用,但您可以禁用某些角度优化以回到之前的行为,如in this issue on the Material repo所述。

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

基本上,你在这里做的是配置$ compileProvider以便像往常一样工作。如果你不这样做,那么组件的初始化代码应该驻留在$ onInit()回调中,如in this breaking change on Angular's changelog所述

相关问题