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

If model is not ready by rendering, there's an error #31

Closed
elado opened this issue Mar 1, 2014 · 8 comments
Closed

If model is not ready by rendering, there's an error #31

elado opened this issue Mar 1, 2014 · 8 comments
Labels

Comments

@elado
Copy link
Contributor

elado commented Mar 1, 2014

My data source comes from a service, on a callback. Until the callback it's not available.

TypeError: Cannot read property 'length' of undefined
    at Deckgrid.$$onModelChange (http://localhost/assets/angular-deckgrid/angular-deckgrid.js?body=1:153:19)

If I have it as an empty array, $scope.data = [] before the service, it does work. My guess is that the code should also check if there's something in the model before accessing its .length.

@gabriel4649
Copy link

I'm having this issue too.

@gabriel4649
Copy link

Any pointers as to how to fix this? I might have the time to send a PR.

@nicoabie
Copy link

nicoabie commented Mar 6, 2014

@climatewarrior an easy way to fix it would be this.

if ((oldModel? oldModel.length : 0) !== newModel.length) {
self.$$createColumns();
}

OR

if ((oldModel || []).length !== newModel.length) {
self.$$createColumns();
}

I don't know if there is something more angular way to do it. I am assuming that when the model changes, it will change to a valid array

@gabriel4649
Copy link

@nicoabie Thanks!! Now it works :) Although I'm still getting the following error: Error: newModel is undefined but the functionality is not affected.

@nicoabie
Copy link

nicoabie commented Mar 9, 2014

@climatewarrior you are welcome, can you provide an example in jsfiddle or similar to analyze it further?

akoenig pushed a commit that referenced this issue Mar 16, 2014
@akoenig
Copy link
Owner

akoenig commented Mar 16, 2014

Okay, implemented a fallback mechanism here. Can anybody doublecheck if the problem still persists?

@akoenig akoenig added the review label Mar 16, 2014
@gabriel4649
Copy link

@akoenig It's working just fine for me, thanks!!

@akoenig
Copy link
Owner

akoenig commented Mar 17, 2014

Okay, cool. Thanks for the check :) Release v0.4.1 is live.

@akoenig akoenig closed this as completed Mar 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants