thinkster-django-angular-tutorial
thinkster-django-angular-tutorial copied to clipboard
Issue with the PostController when window is resized
When I would refresh sometimes the posts wouldn't appear.
The listener function(render) which watches the window width doesn't work with the listener expression. The parameters being passed are window width sizes not the current and old value of the posts array.
Following the tutorial exactly, at the posts.controller.js, completing that chapter, I get this error in console when I visit the homepage.
TypeError: Cannot read property 'length' of undefined at http://localhost:8000/static/javascripts/posts/controllers/posts.controller.js:76:33 at Array.map (native) at columnMapFn (http://localhost:8000/static/javascripts/posts/controllers/posts.controller.js:75:30) at Array.map (native) at approximateShortestColumn (http://localhost:8000/static/javascripts/posts/controllers/posts.controller.js:64:31) at render (http://localhost:8000/static/javascripts/posts/controllers/posts.controller.js:112:24) at Object.$watchCollectionAction as fn at Scope.$get.Scope.$digest (http://localhost:8000/static/bower_components/angular/angular.js:14308:29) at Scope.$get.Scope.$apply (http://localhost:8000/static/bower_components/angular/angular.js:14571:24) at done (http://localhost:8000/static/bower_components/angular/angular.js:9698:47)
Anyway related to your patch above?
This branch fixes the post not appearing on refresh issue but doesn't fix the issue where post doesn't re-align properly after window resize...
Also, I think you made a typo:
if (oldWindowSize !== oldWindowSize){
should probably be:
if (newWindowSize !== oldWindowSize){