Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度偏移错误,2.1.x=>;4.1.3_Angular_Webpack_Migration - Fatal编程技术网

Angular 角度偏移错误,2.1.x=>;4.1.3

Angular 角度偏移错误,2.1.x=>;4.1.3,angular,webpack,migration,Angular,Webpack,Migration,我正在更新一个相当大的项目,这是它的更新时间表过期的方式 我收到一个与browserdomadapter相关的错误: 类型“BrowserDomAdapter”上不存在属性“query” 代码如下: 构造函数(titleService:Title){ this.titleService=titleService; this.dom=新的BrowserDomAdapter(); this.headElement=this.dom.query('head'); this.metaDescriptio

我正在更新一个相当大的项目,这是它的更新时间表过期的方式

我收到一个与browserdomadapter相关的错误:

类型“BrowserDomAdapter”上不存在属性“query”

代码如下:

构造函数(titleService:Title){
this.titleService=titleService;
this.dom=新的BrowserDomAdapter();
this.headElement=this.dom.query('head');
this.metaDescription=this.getOrCreateMetaElement('description');
this.robots=this.getorCreateMetaine('robots');
}
以及:

private getorCreateMateElement(名称:string):HTMLElement{
让el:HTMLElement;
el=this.dom.query('meta[name='+name+']);
如果(el==null){
el=this.dom.createElement('meta');
el.setAttribute('名称',名称);
this.headElement.appendChild(el);
}
返回el;
}   

我还必须从webpack 1.x.x迁移到最新版本。

不再支持BrowsDomAdapter。新方法是注入文档

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();
    }
}

检查。Angular的问题跟踪器中的google/search you问题总是很好这只是从@developer之前评论的链接粘贴的副本…在发布任何评论之前,我一直在阅读整个线程,直到找到我提供的解决方案,这样他就不必去爬过旧的问题线索,也不必向任何可能偶然发现这个问题的人清楚地提供答案