Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue on watch #46

Open
pabulo opened this issue Jan 28, 2015 · 0 comments
Open

Issue on watch #46

pabulo opened this issue Jan 28, 2015 · 0 comments

Comments

@pabulo
Copy link

pabulo commented Jan 28, 2015

Hi,

I was including your directive in another directive and saw that the table didn't get populated with data. After some analysis we concluded that it was due to scope.$parent was not available so we change a bit your code to:

if (!scope.htSettings) {
scope.htSettings = {};
}
var watchDataRows = scope.$watchCollection('datarows', function () {
scope.htSettings['data'] = scope.datarows;
scope.hotInstance = settingFactory.initializeHandsontable(element, scope.htSettings);
if (scope.htSettings.columns) {
for (var i = 0, length = scope.htSettings.columns.length; i < length; i++) {

                            if (scope.htSettings.columns[i].type == 'autocomplete') {
                                if (typeof scope.htSettings.columns[i].optionList === 'string') {
                                    var optionList = {};
                                    var match = scope.htSettings.columns[i].optionList.match(/^\s*(.+)\s+in\s+(.*)\s*$/);
                                    if (match) {
                                        optionList.property = match[1];
                                        optionList.object = match[2];
                                    } else {
                                        optionList.object = optionList;
                                    }
                                    scope.htSettings.columns[i].optionList = optionList;
                                }

                                autoCompleteFactory.parseAutoComplete(scope.hotInstance, scope.htSettings.columns[i], scope.datarows, true);
                            }
                        }
                        scope.hotInstance.updateSettings(scope.htSettings);
                    }
                });
                angular.extend(scope.htSettings, settingFactory.setHandsontableSettingsFromScope(htOptions, scope));


                scope.htSettings.afterChange = function () {
                    if (!$rootScope.$$phase) {
                        scope.$apply();
                    }
                };

                scope.$on('$destroy', function () {
                    watchDataRows();
                });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants