I’m learning Angular and have created an enhanced version of the OWM widget. Before I release it, I would appreciate if someone with Angular knowledge can review the code.
I’ve used $interval to trigger the first load, there must be antother way of doing this? And I used $interval to retrieve fresh data every x seconds. There’s probably an existing trigger from OH where I can hook on to refresh.
Are you using your own controller? HabPanel broadcasts the item update on rootscope are you can see here so the only thing you need is do a $rootScope.$on(...)
You do not need to use any interval based logic. Let OHService do it for you. It opens an EvenSource to OH’s /rest/events and broadcasts the changes. You can see I do the same thing here
$interval(function() { // First load
loadOwmForecast();
}, 500, 1);
you’r redeclaring a function that calls another function. Just pass it directly
$interval(loadOwmForecast, 500, 1)
And I’m not entirely sure what you’re tying to do in the controller. Looks like I could have done all that in the template (HTML) with proper ng-repeat and getItem calls?
I suppose you can just call your function without the $interval, directly in the controller.
I assume the controller is just to call mostly for getClosest()