Reputation: 276
I am working on updating quite a hefty project, that is way past due on its update schedule.
I am getting an error related to browserdomadapter:
Property 'query' does not exist on type 'BrowserDomAdapter'.
Here is the code:
constructor(titleService: Title) {
this.titleService = titleService;
this.dom = new BrowserDomAdapter();
this.headElement = this.dom.query('head');
this.metaDescription = this.getOrCreateMetaElement('description');
this.robots = this.getOrCreateMetaElement('robots');
}
and:
private getOrCreateMetaElement(name: string): HTMLElement {
let el: HTMLElement;
el = this.dom.query('meta[name=' + name + ']');
if (el === null) {
el = this.dom.createElement('meta');
el.setAttribute('name', name);
this.headElement.appendChild(el);
}
return el;
}
I also had to migrate from webpack 1.x.x to the latest as well.
Upvotes: 1
Views: 59
Reputation: 9260
BrowsDomAdapter is no longer supported. The new method is to inject DOCUMENT.
import { Component, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
@Component({})
export class MyClass {
constructor (@Inject(DOCUMENT) private document) { }
doSomething() {
this.document.someMethodOfDocument();
}
}
Upvotes: 2