To establish two-way communication between a custom Angular component and the main page in Creatio Freedom UI, use a shared attribute, @Input() / @Output() decorators, and standard binding patterns.
In your page schema, create an attribute that will hold the data structure shared between the component and the page:
"TransferAttribute": {
"value": {
"listValue": []
}
}
diff{
"operation": "insert",
"name": "CustomComponent",
"values": {
"value": "$TransferAttribute",
"type": "usr.Component"
},
"parentName": "ParentName",
"propertyName": "items",
"index": 0
}
value binds the page attribute to the component.type should be the name of your registered component.Define a TypeScript interface to describe the payload being transferred:
export interface MyPayload {
listValue: any[];
}
import { CrtInput, CrtOutput } from '@creatio-devkit/common';
import {EventEmitter, Input, Output } from '@angular/core';
@Input() and @Output() in the Angular componentBind the value and prepare it to emit updates:
@Input()
@CrtInput()
value: MyPayload = { listValue: [] };
@Output()
@CrtOutput()
valueChange = new EventEmitter<MyPayload>();
When you update the value inside the component: