I'm trying to popup a modal on onChange event of a formly custom checkbox. Modal turnup okay, but can't make the buttons working :(. Where I'm doing wrong?

```
{
                    key: 'coordinatesToLocateSite',
                    className: 'col-sm-8 col-md-8 col-lg-8',
                    type: 'custom_checkbox',
                    templateOptions: {
                        label: 'Use coordinates to locate site',
                        onChange: function($viewValue, $modelValue, scope) {

                            if ($viewValue === true) {
                                scope.modalInstance = scope.$uibModal.open({
                                    animation: true,
                                    templateUrl: 'address_replace_coordinates_check.html'                                    
                                })
                            }

                            function check() {
                                if (scope.modalInstance) {
                                    scope.modalInstance.close();
                                }
                            }

                            scope.uncheck = function uncheck(keyName) {
                                $scope.model[keyName] = !$scope.model[keyName];
                                if (scope.modalInstance) {
                                    scope.modalInstance.close();
                                }
                            }
                        }                        
                    },

                    expressionProperties: {
                        'templateOptions.disabled': 'formState.disabled'
                    }
                }

```

In the template my button are as follows,

```
<div class="modal-footer">
        <button class="btn btn-warning" type="button" ng-click="check()">Ok</button>
        <button class="btn btn-primary" type="button" ng-click="uncheck('coordinatesToLocateSite')">Cancel</button>
    </div>

```

And lastly, I've tried the following as well.

```
formlyConfigProvider.setType({
            name: 'custom_checkbox',
            templateUrl: 'bcsa_checkbox.html',
            wrapper: ['bootstrapHasError'],
            apiCheck: function apiCheck(check) {
                return {
                    templateOptions: {
                        onChange: check.oneOfType([check.string, check.func]),
                        label: check.string
                    }
                };
            },
            controller: /* @ngInject */ function($scope, $sce, $uibModal) {
                'ngInject';
                $scope.$uibModal = $uibModal;
                var markerOfRequired = '<span class="red"> \n<strong> \n* \n</strong> \n</span>';
                $scope.labelDisplay = $sce.trustAsHtml($scope.to.label + ($scope.to.required ? markerOfRequired : ''));

                $scope.onChange = onChange;
                $scope.check = check;
                $scope.uncheck = uncheck;

                function onChange($event) {
                    if (angular.isString($scope.to.onChange)) {

                        return $scope.$eval($scope.to.onChange, { $event: $event, $scope: $scope });

                    } else {

                        return $scope.to.onChange($event, $scope);
                    }
                }

                function check() {
                    if (scope.modalInstance) {
                        scope.modalInstance.close();
                    }
                }

                function uncheck(keyName) {
                    $scope.model[keyName] = !$scope.model[keyName];
                    if (scope.modalInstance) {
                        scope.modalInstance.close();
                    }
                }
            }
        });

```