Not sure what I am missing. This works fine in when I run it in my local using ng build and ng serve
But when I moved to production, it started behaving like this. Then I tried to reproduce in my local using ng build --prod
and ng serve --prod
. Now I can reproduce the issue in my local as well.
What I want: the datepicker popup should appear with correct styling and should be able to select date
What is working now: in local it is working with ng build and ng serve
What is the issue: in prod (or using ng build --prod
and ng serve --prod
), the popup shows empty. please the below picture
What I have tried: After researching I found some suggestions to try out with ng serve --prod --build-optimizer=false
also tried by making "buildOptimizer": false
in angular.json
Erro: When I click on the datepicker icon, I can below error
TypeError: Cannot read property 'getElementsByClassName' of
Please let me know what more information is required to debug this issue. I was thinking of creating a stackblitz, but it seems to be working in stackblitz.
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>
Seems to be a defect in material datepicker. Not a solution, but a workaround that worked for me.
Can you try making below changes in your angular.json
"optimization": false
"aot": false
"buildOptimizer": false