<input> 模板的 ng-grid 问题

ng-grid issue with <input> template

我有以下 ng-grid 定义:

$scope.gridActivities = {
    data: 'activities'
    , multiSelect: false
    , columnDefs: [
        { field: 'ID', displayName: 'ID', visible: false },
        { field: 'AppliedWorkType.WorkType.Name', displayName: 'Type' },
        { field: 'CreatedOn', displayName: 'Date', cellFilter: 'date:\'MM/dd/yyyy\'' },
        { field: 'NonBillableHours', displayName: 'Unbilled Hours' },
        { field: 'BillableHours', displayName: 'Billed Hours', cellTemplate: '<input type="number" class="form-control" ng-pattern="/^\d{0,9}(\.\d{1,9})?$/" ng-model="row.entity.BillableHours"/>' }
    ]
}

由于 activities 默认加载和显示,输入正确地在 BillableHours 中具有正确的值,我可以在输入框中看到它们。但是,当我更改值(从 5 到 6)然后通过调试和查看 $scope 查看 activity 时,activity.BillableHours 已切换为 undefined

我正在使用与我已经使用过的复选框类似的方法:

{ field: 'ApprovalAuthority', displayName: 'Approval Authority', cellTemplate: '<input class="control-label" style="margin-top: 8px;margin-left: 8px" type="checkbox" ng-model="row.entity.ApprovalAuthority" />' }

为什么这适用于复选框而不适用于文本框?

您忘记转义 ng-pattern 中的“\”字符

只要把ng-pattern="/^\d{0,9}(\.\d{1,9})?$/"改成ng-pattern="/^\d{0,9}(\.\d{1,9})?$/"

这是一个有效的 plunker