Ng-grid with <input> template

I have the following ng grid definition:

$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"/>' }
    ]
}

      

As the activities

default is loaded and displayed, the input correctly has the correct values โ€‹โ€‹inside BillableHours

and I can see them in the input field. However, when I change the value (5 to 6) and then I look at the activity while debugging and looking at the $ scope activity.BillableHours

switched to undefined

.

I'm using a similar method for something I've already worked with with checkboxes:

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

      

Why does this work for checkboxes but not for text boxes?

+3


source to share


1 answer


You forgot to escape the '\' character in your ng pattern

Just change ng-pattern="/^\d{0,9}(\.\d{1,9})?$/"

tong-pattern="/^\\d{0,9}(\\.\\d{1,9})?$/"



This is where the plunker works

+1


source







All Articles