I believe .indexOf is used to get index of widget in widgets, but it's not used correctly. Maybe `.indexOf($scope.widgets, widget)` ?