pandu das pandu das - 1 year ago 111
jQuery Question

angular js error : Argument 'questionsCtrl' is not a function

I am trying to call a controller when ui loads, but getting below error.

angular.js:9778 Error: [ng:areq] Argument 'questionsCtrl' is not a function, got string
at assertArg (
at assertArgFn (
at nodeLinkFn (
at compositeLinkFn (
at publicLinkFn (
at updateView (

my code is:


(function () {
"use strict";
var app = angular.module("autoQuote",["ui.router"]);

app.config(["$stateProvider","$urlRouterProvider", function($stateProvider,$urlRouterProvider){

.state("step1", {
url : "/",
templateUrl : "step1.html",
controller: "questionsCtrl"
.state("step2", {
url : "/step2",
templateUrl : "step2.html",
controller: "questionsCtrl"


(function () {
"use strict";


function questionsCtrl() {
console.log('here in questionsCtrl');


Answer Source

You need to refer the function when defining the controller.

.controller("questionsCtrl", questionsCtrl);
                             ^^^^^^^^^^^^^     : Function reference, not a string

The first parameter to the controller() is the name of the controller and second is the mappings.

I'll suggest to use following min-safe syntax.

.controller('questionsCtrl', ['$scope', function ($scope) {


To refer to controller function

.controller('questionsCtrl', ['$scope', questionsCtrl]);

function questionsCtrl($scope) {
    console.log('In questionsCtrl');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download