Federick Jons Federick Jons - 1 year ago 111
AngularJS Question

Add $scope to controller

May be is a stupid question... but I wanna make best practices. So.. I have my controller:

(function() {
'use strict';

.controller('CanchaController', CanchaController);

CanchaController.$inject = ['$state', 'canchaService'];

function CanchaController($state, canchaService) {
var vm = angular.extend(this, {
canchasComplejo: []

(function activate() {

//funcion que llama al servicio para obtener las canchas del complejo
function cargarCanchasComplejo() {
.then(function(canchasComplejo) {
vm.canchasComplejo = canchasComplejo;

Now I need to call a function and make changes (is a collapse list) with


ng-class="{active: isGroupShown(group)}".

For this I need to use $scope
How can I integrate in my controller the $scope? Because I the most controller are like:

.controller('MyCtrl', function($scope) {

Thanks for helping!

Answer Source

you can inject $scope in the same way you are inject $state so:

CanchaController.$inject = ['$state', '$scope', 'canchaService'];

function CanchaController($state, $scope, canchaService) { ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download