Custom widget: angularjs controller question


I’m loading a custom controller.js file via oc-lazy-load.
In my controller.js file, how can I refer to config.myitem?

In switch.widget.js var item = OHService.getItem(vm.widget.item); is used.
How can I refer to my custom widget ctrl settings?

You have to inject $scope in your controller, then you’ll be able to access the config with e.g. $scope.config.item

    .controller('mycontroller', ['$scope', function($scope) {
        // $scope will also include the scope of the containing widget,
        // so all these work:
        // var itemName = $scope.config.item;
        // var state = $scope.itemState($scope.config.item);
        // var lights = $scope.itemsInGroup('Lights'); // returns an array
        // $scope.sendCmd($scope.config.item, 'ON');