1

I've just installed the following package with bower:

https://github.com/urish/angular-spinner

The package is added successfully. I've also added:

<script src="bower_components/spin.js/spin.js"></script>
<script src="bower_components/angular-spinner/angular-spinner.js"></script>

When I try to inject it like this:

(function()
{
    angular.module('employeeApp',['angularSpinner']).controller('schoolController', schoolController);

It crashes and I receive the error:

Argument 'indexController' is not a function, got undefined

When I remove ['angularSpinner'] everything works again.

What should I do?

--EDIT--

indexController

angular.module('employeeApp').controller('indexController', indexController);

function indexController($location, authenticationFactory,constants)
{
    var vm = this;

    vm.setName = function()
    {
        return constants.firstname;
    }
}
8
  • 1
    What is indexController? Commented Mar 29, 2016 at 12:32
  • some where you have referenced the controller wrong, can you share the indexController code? Commented Mar 29, 2016 at 12:32
  • yea need more code also what is (function() { leading to? need code before and after that Commented Mar 29, 2016 at 12:33
  • 1
    the module is getting defined twice somewhere Commented Mar 29, 2016 at 12:39
  • 1
    Thanks all! I declared it twice. Commented Mar 29, 2016 at 12:43

2 Answers 2

1

in angular you create module for your app and there you specify the dependencies. and once you create controller or service you get the module by name and create controller\ service in that module.

//create module for app
 angular.module('employeeApp', [ /*add your dependencies here*/ ]);

//create controller\ service 
angular.module('employeeApp').controller(function(){
   //controller implementation
 });

what might happen is you may re initialize your app by mistake.

Sign up to request clarification or add additional context in comments.

Comments

0

for simplification you could store your angular module in a variable as follows:

var app = angular.module('employeeApp', ['angularSpinner']);

and define a controller like this:

app.controller('indexController',function(angularSpinner){
   //controller code here
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.