不知道我错过了什么。当我使用 ng build 和 ng serve 在本地运行它时,这可以正常工作
但是当我转向生产时,它开始表现得像这样。然后我尝试在我的本地使用ng build --prod
和复制ng serve --prod
。现在我也可以在本地重现该问题。
我想要什么:日期选择器弹出窗口应该以正确的样式出现,并且应该能够选择日期
现在正在做什么:在本地它正在使用 ng build 和 ng serve
问题是什么:在 prod (或使用ng build --prod
and ng serve --prod
)中,弹出窗口显示为空。请看下图
我尝试过的:经过研究,我发现了一些可以尝试的建议,ng serve --prod --build-optimizer=false
也可以通过制作"buildOptimizer": false
来尝试angular.json
错误:当我点击日期选择器图标时,我会出现以下错误
TypeError: Cannot read property 'getElementsByClassName' of
请让我知道调试此问题需要更多信息。我正在考虑创建一个 stackblitz,但它似乎在 stackblitz 中工作。
包.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>