I've change the code to:
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, lampsFactory) {
lampsFactory.getLamps(function(results) {
$scope.lamps = results;
});
$scope.getLampState = function(lampID){
lampsFactory.getLampState(function(results) {
console.log(results.state.on);
return results.state.on;
},lampID);
};
});
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);
}
};
});
and it works! Thanks!