Angular-这是编写初始化函数的另一种方法吗?

时间:2019-04-20 15:50:19

标签: angular typescript kendo-ui-angular2

请参阅此链接,其中包括StackBlitz链接,因为我无法直接链接到该链接。
https://www.telerik.com/kendo-angular-ui/components/grid/editing/editing-row-click/

在此Kendo UI Angular示例中,为在线编辑设置了网格。我很好奇他们在主类定义之外如何定义fromgroup。这仅仅是定义“初始化”方法的另一种方法吗?将其作为方法放入类本身的另一种写法是什么?

const createFormGroup = dataItem => new FormGroup({
    'Discontinued': new FormControl(dataItem.Discontinued),
    'ProductID': new FormControl(dataItem.ProductID),
    'ProductName': new FormControl(dataItem.ProductName, Validators.required),
    //'UnitPrice': new FormControl(dataItem.UnitPrice),
    'UnitsInStock': new FormControl(dataItem.UnitsInStock, Validators.compose([Validators.required, Validators.pattern('^[0-9]{1,3}')]))
});

0 个答案:

没有答案
相关问题