I started working on a little AngularJS - Philips Hue project and I'm kinda stuck...
I'm fairly new to AngularJS... but here goes.
What I want to do is to list the lamps I have, the status of the lamps and a toggler to switch them.
I decided to build a factory (based on this article: http://davidsalter.com/2013/08/16/using-angular-dot-js-factories-to-get-remote-data/) for the data getting/putting:
app.factory('lampsFactory', function($http) {
return {
getLamps: function(callback) {
$http.get('http://172.16.0.2/api/newdeveloper/lights').success(callback);
},
getLampState: function(callback, lampID) {
$http.get('http://172.16.0.2/api/newdeveloper/lights/'+ lampID).success(callback);
}
};
});
The getLamps function works as it should but I don't know how to get lamp data based on an id. I tried to add an extra paremeter but that did not work.
Can you please help me and push me in the right direction?
I also have a plunker: http://plnkr.co/edit/ySa0PVBahM7sxU4lasgP
Thanks!