我是Angular的新手,正在使用Angular Materials。我在选择垫子时出现跟随错误。我的代码如下
<mat-form-field>
<mat-select placeholder="Owner Type">
<mat-option value="Individual">Individual</mat-option>
<mat-option value="Corporate">Corporate</mat-option>
</mat-select>
</mat-form-field>
错误是:
ERROR Type Error: this._document.createElement is not a function
at n._createHostElement (main.6b5485aaca2669c7d428.js:1)
at n.create (main.6b5485aaca2669c7d428.js:1)
at n._createOverlay (main.6b5485aaca2669c7d428.js:1)
at n._attachOverlay (main.6b5485aaca2669c7d428.js:1)
at n.ngOnChanges (main.6b5485aaca2669c7d428.js:1)
at main.6b5485aaca2669c7d428.js:1
at main.6b5485aaca2669c7d428.js:1
at eu (main.6b5485aaca2669c7d428.js:1)
at ju (main.6b5485aaca2669c7d428.js:1)
at main.6b5485aaca2669c7d428.js:1
依赖项
"dependencies": {
"@agm/core": "^1.0.0-beta.5",
"@angular/animations": "^7.2.3",
"@angular/cdk": "^7.3.0",
"@angular/common": "^7.2.6",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "^7.2.6",
"@angular/http": "^7.2.2",
"@angular/material": "^7.3.3",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"@types/jquery": "^3.3.29",
"angular-bootstrap-datetimepicker": "^2.2.1",
"bootstrap": "^3.4.1",
"core-js": "^2.5.4",
"datatables.net-bs4": "^1.10.19",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"ng-pick-datetime": "^5.2.6",
"rxjs": "^6.4.0",
"rxjs-compat": "^6.4.0",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"},
“ devDependencies”:{ “ @ angular-devkit / build-angular”:“〜0.12.0”, “ @ angular / cli”:“〜7.2.1”, “ @ angular / compiler-cli”:“〜7.2.0”, “ @ angular / language-service”:“〜7.2.0”, “ @ types / node”:“〜8.9.4”, “ @ types /茉莉花”:“〜2.8.8”, “ @ types / jasminewd2”:“〜2.0.3”, “ codelyzer”:“〜4.5.0”, “茉莉花芯”:“〜2.99.1”, “ jasmine-spec-reporter”:“〜4.2.1”, “ karma”:“〜3.1.1”, “ karma-chrome-launcher”:“〜2.2.0”, “业力报废的伊斯坦布尔记者”:“〜2.0.1”, “业力茉莉花”:“〜1.1.2”, “ karma-jasmine-html-reporter”:“ ^ 0.2.2”, “量角器”:“〜5.4.0”, “ ts-node”:“〜7.0.0”, “ tslint”:“〜5.11.0”, “ typescript”:“〜3.2.2”}
请有人协助我解决此问题。
答案 0 :(得分:0)
这可能是您导入Observable
的方式的原因。
代替此import {Observable} from 'rxjs'
;试试这个:import {Observable} from 'rxjs/Observable'
;
答案 1 :(得分:0)
只需在ts文件中添加一个数组,例如 ownerType = [“个人”,“公司”]; 然后在app.module.ts
中添加以下内容import {MatSelectModule} from '@angular/material/select';
@NgModule({
imports: [ ..., MatSelectModule, ...]
})
<mat-form-field>
<mat-select placeholder="Owner Type">
<mat-option *ngFor="let owner of ownerType" [value]="owner">
{{owner}}
</mat-option>
</mat-select>
</mat-form-field>
答案 2 :(得分:0)
我在该应用程序中使用了第三方插件作为日期和时间选择器插件,它与所有材料冲突。现在,我卸载了日期和时间选择器插件,现在可以正常使用了。