При работе с Angular6 возникает ошибка, хотя моё приложение может работать и
app-comp-scss @import url (// db.onlinewebfonts.com/c/1ee33a9b49804d9ee832fd5242851181?family= Соединения); my-app {padding: 0; } body {background-color: rgba (242, 242, 242, 1); }
kendo-drawer-content {
padding: 20px;
height: 100%;
overflow-y: auto;
}
kendo-drawer-container {
width: 100%;
height: calc(100vh - 70px);
}
.k-drawer-wrapper {
padding-top: 20px;
height: 100%;
// background-image: linear-gradient(#3f92cd, #fff);
}
.drawer-toogler {
position: absolute;
top: 50%;
width: 20px;
margin-left: -20px;
height: 80px;
box-shadow: 10px 0px 15px 0px rgba(0, 0, 0, 0.15) !important;
font-size: 24px;
color: #919191;
background-color: #fff;
}
---------------------------------------- --------------------------
hier-def-comp-TS
import { Component, OnInit, Input, Output, EventEmitter, Inject } from '@angular/core';
import { HttpErrorResponse } from '@angular/common/http';
import { Validators, FormGroup, FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { map, findIndex } from 'rxjs/operators';
// Kendo
import { GridDataResult } from '@progress/kendo-angular-grid';
import { State, process } from '@progress/kendo-data-query';
import { Hierarchy } from '../../../../Models/hierarchy';
import { HierarchyDefinitionService } from '../../../../Services/hierarchy-definition.service';
import { IFormInput } from '../../../dynamic-form/dynamic-form/dynamic-form.component';
@Component({
selector: 'app-hierarchy-definition',
templateUrl: './hierarchy-definition.component.html',
styleUrls: ['./hierarchy-definition.component.scss'],
})
export class HierarchyDefinitionComponent implements OnInit {
private readonly categoryRegex = '^(?=.*[a-zA-Z0-9_,./: -])[a-zA-Z0-9_,./: -]+$';
categoryForm = true;
isDisplayAlert = false;
message = '';
isEdit = false;
editRowName = '';
hierarchyTypeList: any[] = [];
hierarchyReportingPurposeList: any[] = [];
hierarchyRecordYearList: any[] = [];
hierarchyEntityList: any[] = [];
hierarchyLevelList: any[] = [];
public hierarchyData: Observable<GridDataResult>;
public gridState: State = {
sort: [],
skip: 0,
take: 5,
};
public gridId = 'hierarchyId';
public gridOption = [
{
field: 'hierarchyName',
title: 'Hierarchy Name',
width: 100,
},
{
field: 'hierarchyDescription',
title: 'Hierarchy Description',
width: 180,
},
{
field: 'hierarchyType',
title: 'Hierarchy Type',
width: 120,
},
{
field: 'levels',
title: 'Number of levels',
width: 120,
},
{
field: 'recordYear',
title: 'Record Year',
width: 100,
},
{
field: 'reportingPurpose',
title: 'Reporting Purpose',
width: 150,
},
{
field: 'legalEntity',
title: 'Legal Entity',
width: 100,
},
];
public inputs: IFormInput[] = [
{
inputField: 'hierarchyName',
inputLabel: 'Hierarchy Name',
inputType: 'text',
validations: [
{
errorMessage: 'Hierarchy Name is required',
validator: Validators.required,
name: 'required',
},
{
errorMessage: `Comma (,), hyphen (-), underscore(_), spaces() ,dot(.), forward
slash (/) , colon(:) and alphanumeric are allowed`,
validator: Validators.pattern(this.categoryRegex),
name: 'pattern',
},
],
},
{
inputField: 'hierarchyDescription',
inputLabel: 'Hierarchy Description',
inputType: 'text',
validations: [
{
errorMessage: 'Hierarchy Description is required',
validator: Validators.required,
name: 'required',
},
{
errorMessage: `Comma (,), hyphen (-), underscore(_), spaces() ,dot(.), forward
slash (/) , colon(:) and alphanumeric are allowed`,
validator: Validators.pattern(this.categoryRegex),
name: 'pattern',
},
],
},
{
inputField: 'hierarchyType',
inputLabel: 'Hierarchy Type',
inputType: 'dropdown',
data: this.hierarchyTypeList,
validations: [
{
errorMessage: 'Hierarchy Type is required',
validator: Validators.required,
name: 'required',
},
],
},
{
inputField: 'levels',
inputLabel: 'Number of levels',
inputType: 'dropdown',
data: this.hierarchyLevelList,
validations: [
{
errorMessage: 'Number of levels is required',
validator: Validators.required,
name: 'required',
},
],
},
{
inputField: 'recordYear',
inputLabel: 'Record Year',
inputType: 'dropdown',
data: this.hierarchyRecordYearList,
validations: [
{
errorMessage: 'Record Year is required',
validator: Validators.required,
name: 'required',
},
],
},
{
inputField: 'legalEntity',
inputLabel: 'Legal Entity',
inputType: 'dropdown',
data: this.hierarchyEntityList,
validations: [
{
errorMessage: 'Legal Entity is required',
validator: Validators.required,
name: 'required',
},
],
},
{
inputField: 'reportingPurpose',
inputLabel: 'Reporting Purpose',
inputType: 'dropdown',
data: this.hierarchyReportingPurposeList,
validations: [
{
errorMessage: 'Reporting Purpose is required',
validator: Validators.required,
name: 'required',
},
],
},
];
public selectedHierarchy: Hierarchy;
public isNew: boolean;
search: string;
dialogOpened = false;
isBulk = true;
deleteItem = null;
public mySelection: number[] = [];
hierarchySelected: any;
displayHierarchyForm: boolean;
constructor(private hierarchyDefinitionService: HierarchyDefinitionService) {}
ngOnInit() {
this.hierarchyData = this.hierarchyDefinitionService.pipe(map((data) => process(data, this.gridState)));
this.hierarchyDefinitionService.read();
this.initForm();
}
initForm(): void {}
onStateChange(state: State): void {
this.gridState = state;
this.hierarchyDefinitionService.read();
}
addHandler(): void {
this.selectedHierarchy = new Hierarchy();
this.isNew = true;
}
editHandler({ dataItem }): void {
this.selectedHierarchy = dataItem;
}
cancelHandler(): void {
this.selectedHierarchy = undefined;
}
saveHandler(category: Hierarchy): void {
this.hierarchyDefinitionService.save(category, this.isNew);
}
removeHandler({ dataItem }): void {
this.isBulk = false;
this.manageDialog();
this.deleteItem = dataItem;
}
searchFn(event): void {
this.hierarchyDefinitionService.filterData(this.search);
}
bulkActionsFn(): void {
this.manageDialog();
if (this.isBulk) {
this.hierarchyDefinitionService.bulkDelete(this.mySelection);
this.mySelection = [];
this.message = 'row(s) removed';
this.isDisplayAlert = true;
} else {
this.isBulk = true;
this.hierarchyDefinitionService.remove(this.deleteItem);
this.mySelection = [];
this.message = 'row(s) removed';
this.isDisplayAlert = true;
}
}
showCategoryForm(value: string): void {
this.categoryForm = false;
this.displayHierarchyForm = true;
if (value === 'new') {
this.selectedHierarchy = new Hierarchy();
this.isEdit = false;
}
}
getMenu() {
let allData = [];
this.hierarchyDefinitionService.subscribe((x) => {
allData = x;
});
allData.forEach((x) => {
this.hierarchyTypeList.push(x.hierarchyType);
this.hierarchyReportingPurposeList.push(x.reportingPurpose);
this.hierarchyRecordYearList.push(x.recordYear);
this.hierarchyEntityList.push(x.legalEntity);
this.hierarchyLevelList.push(x.levels);
});
}
manageDialog() {
this.dialogOpened = !this.dialogOpened;
}
confirmDialog(val) {
val === 'yes' ? this.bulkActionsFn() : this.manageDialog();
}
clearPopup() {
this.isDisplayAlert = false;
}
onSaveHierarchy(hierarchy: Hierarchy) {
console.log(hierarchy);
this.hierarchyDefinitionService.save(hierarchy, true);
this.message = 'row added';
this.isDisplayAlert = true;
}
onEditHierarchy(hierarchy: Hierarchy) {
console.log(hierarchy);
this.hierarchyDefinitionService.save(hierarchy, false);
this.message = 'row edited';
this.isDisplayAlert = true;
}
onCancelForm() {
this.hierarchySelected = new Hierarchy();
this.displayHierarchyForm = false;
}
editGetDataFn(): void {
this.getMenu();
this.showCategoryForm('edit');
}
}
работает правильно Тесты не пройдут. Когда я нажимаю на любую кнопку, я получаю ошибку, поскольку eventEmitter не установлен. выше приведен фрагмент кода файла: