角度材质的日期选择器-产品中的空白弹出窗口

时间:2019-03-25 15:17:07

标签: angular datepicker angular-material angular-material-datetimepicker

不确定我缺少什么。当我使用ng build和ng serve在本地运行它时,这种方法很好用

但是当我开始生产时,它开始表现为这样。然后,我尝试使用ng build --prodng serve --prod在本地复制。现在,我也可以在本地重现该问题。

我想要的是:日期选择器弹出窗口应以正确的样式显示,并且应该能够选择日期

现在正在做什么:在本地正在使用ng build和ng serve

问题是什么:在生产中(或使用ng build --prodng serve --prod),弹出窗口显示为空。请下图

我尝试过的方法:研究后,我发现了一些尝试使用ng serve --prod --build-optimizer=false的建议,也通过在"buildOptimizer": false中制作angular.json来尝试了

错误:当我单击日期选择器图标时,我可以看到以下错误

TypeError: Cannot read property 'getElementsByClassName' of

请让我知道调试此问题需要更多的信息。我当时想创建一个堆栈闪电战,但似乎可以在堆栈闪电战中正常工作。

package.json:

  "dependencies": {
    "@angular/animations": "^7.0.3",
    "@angular/cdk": "^7.0.3",
    "@angular/common": "~7.0.0",
    "@angular/compiler": "~7.0.0",
    "@angular/core": "~7.0.0",
    "@angular/flex-layout": "^7.0.0-beta.19",
    "@angular/forms": "~7.0.0",
    "@angular/http": "~7.0.0",
    "@angular/material": "^7.0.3",
    "@angular/material-moment-adapter": "^7.3.4",
    "@angular/platform-browser": "~7.0.0",
    "@angular/platform-browser-dynamic": "~7.0.0",
    "@angular/router": "~7.0.0",
    "@swimlane/ngx-charts": "^10.1.0",
    "angular-google-charts": "^0.1.3",
    "bootstrap": "^4.1.3",
    "chart.js": "^2.8.0",
    "core-js": "^2.5.4",
    "dotenv": "^7.0.0",
    "hammerjs": "^2.0.8",
    "jquery": "^3.3.1",
    "moment": "^2.24.0",
    "ng-pick-datetime": "^5.2.6",
    "ng2-charts": "^2.0.3",
    "ng2-tooltip-directive": "^2.1.8",
    "ng4-charts": "^1.0.2",
    "ngx-cookie-service": "^2.1.0",
    "rxjs": "~6.3.3",
    "rxjs-compat": "^6.3.3",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.11.4",
    "@angular/cli": "~7.0.2",
    "@angular/compiler-cli": "~7.0.0",
    "@angular/language-service": "~7.0.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/jquery": "^3.3.29",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ngx-spec": "^2.0.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.1"
  }

html:

        <mat-form-field>
                <mat-label>From Date</mat-label>
                <input  [value]="date.value" matInput [matDatepicker]="summBoardFromDatePicker"  placeholder="From Date" [(ngModel)]="summBoardFromDate">
                <mat-datepicker-toggle  matSuffix [for]="summBoardFromDatePicker"></mat-datepicker-toggle>
                <mat-datepicker #summBoardFromDatePicker></mat-datepicker>
        </mat-form-field>

enter image description here

1 个答案:

答案 0 :(得分:1)

似乎是重要日期选择器中的缺陷。不是解决方案,而是对我有用的解决方法。 您可以尝试在angular.json

中进行以下更改吗?
"optimization": false
"aot": false
"buildOptimizer": false