Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: "@angular/platform-browser/platform-browser" has no exported member 'DOCUMENT'

Tags:

angular

I Have updated Angular version from 7.1.3 to 8.0.0-rc.3 version. After updating the version i am getting following error, during ng build --prod command:- /@angular/platform-browser/platform-browser"' has no exported member 'DOCUMENT'.

Package.json

"devDependencies": {
"@angular/cli": "^8.0.0-rc.3",
"@angular/compiler-cli": "^8.0.0-rc.3",
"@angular/language-service": "^8.0.0-rc.3",
"@ngrx/schematics": "^6.1.2",
"@ngrx/store-devtools": "6.1.2",
"@nrwl/schematics": "7.5.2",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "^2.0.6",
"@types/node": "^12.0.0",
"angular-tslint-rules": "^1.14.0",
"codelyzer": "^5.0.1",
"compodoc": "0.0.41",
"husky": "^0.14.3",
"jasmine-core": "^3.4.0",
"jasmine-marbles": "^0.3.1",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^2.0.0",
"karma-coverage-istanbul-reporter": "^1.4.3",
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "^2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"karma-junit-reporter": "^1.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"lint-staged": "^7.3.0",
"ngrx-store-freeze": "0.2.4",
"prettier": "1.15.3",
"protractor": "^5.4.2",
"rxjs-tslint": "^0.1.7",
"ts-node": "~5.0.1",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"tslint-sonarts": "^1.9.0",
"tslint-teamcity-reporter": "^2.0.0",
"typescript": "^3.4.5"
 }

Component file code is:-

import { DOCUMENT } from '@angular/platform-browser';
@Component({
selector: 'basic-dialog',
styleUrls: ['./dialog.component.scss'],
templateUrl: './dialog.component.html',
animations: [])
])
]
})
export class DialogComponent implements OnChanges, OnDestroy {
  constructor(@Inject(DOCUMENT) private document: Document, private 
  renderer: Renderer2, private element: ElementRef) {}
}

Angular team have deprecated 'DOCUMENT' from @angular/animations. Is there any way to deal with issue of getting document object. Thanks in advance

like image 252
Kamal Kumar Avatar asked May 29 '19 11:05

Kamal Kumar


1 Answers

You are importing from the wrong module. It was depreciated from the platform-browser module a few years ago.

import {DOCUMENT} from '@angular/common';

https://angular.io/api/common#types

like image 71
Reactgular Avatar answered Oct 17 '22 03:10

Reactgular