0

I've a very simple app with no code in it yet. I've removed it to check for this error that I am getting - "angular.js:13708 Error: [ng:areq] Argument 'ClientFileConfigController' is not a function, got undefined"

I've followed the similar patter in my angularjs app (1.5.3) and it works fine. This code is using angularjs (1.5.7) and the only difference is I used bower to individually chose my packages, rather than using nuget.

I am unable to decode this error :-(

app.js

(function () {

    var app = angular.module('ConfigApp', ['ngRoute', 'ngAnimate', 'TreeWidget']);

    app.config(['$routeProvider', function ($routeProvider) {
        var viewBase = '/app/ConfigApp/views/';

        $routeProvider
            .when('/clients', {
                controller: 'ClientFileConfigController',
                templateUrl: viewBase + 'clients.html',
                controllerAs: 'vm'
            })
            //.when('/clients/:clientId/:fileId', {
            //    controller: 'clientfileEditController',
            //    templateUrl: viewBase + 'edit.html',
            //    controllerAs: 'vm'
            //})
            .otherwise({ redirectTo: '/clients' });

    }]);

}());

clientfileConfigController.js

(function(){
    var injectParams = ['$scope'];

    var ClientFileConfigController = function ($scope) {

    }

    ClientFileConfigController.$inject = injectParams;
    angular.module('ConfigApp').controller('ClientFileConfigController', ClientFileConfigController)
}());

index.html

<html ng-app="ConfigApp">
<head>
    <title>Client File Angular Tree Widget</title>
    <meta charset="utf-8" />
</head>
<body ng-cloak>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#about">About</a></li>
                    <li><a href="#/clients">Clients</a></li>
                </ul>
            </div>
        </div>
    </nav>
    .top-buffer { margin-top:20px; }
    <div class="slide-animation-container">
        <div ng-view id="ng-view" class="slide-animation"></div>
    </div>
</body>
</html>

clients.html

<html>
<head>
    <title></title>
    <meta charset="utf-8" />
</head>
<body>
    <h1>Hello World</h1>

    <!--<tree nodes='treeNodes'>-->
</body>
</html>

Error Image

vrkala
  • 21
  • 4

3 Answers3

1

Change your IIFE to this structure:

(function (){
   //your code here
})()

and include your controller in the script

ocespedes
  • 1,233
  • 4
  • 14
  • 27
0

You get this error on two scenarios:

  1. Controller not included in script. (undefined)
  2. Injector dependency couldn't be resolved.
Shintu Joseph
  • 962
  • 7
  • 19
  • The only injector dependency here is $scope for the controller. With AngularJS already referenced, I don't see an issue with this. I've put the controller script as mentioned in my code. – vrkala Jul 15 '16 at 15:07
  • Wat abt the IIFE as @ocespedes said, I dint notice it though – Shintu Joseph Jul 15 '16 at 15:08
  • I might not have included the script file properly...let me review – vrkala Jul 15 '16 at 15:13
  • Thank you...not linking the controller js file properly (typo) in my html is the main issue...so, your point 1 (controller not included in script is the correct hint) – vrkala Jul 15 '16 at 15:18
0

I would say that you need to include the js files in your index html page. Angular is looking for your controller but there is no file specified that contains the code for it

dmunk
  • 31
  • 3