Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument 'controller' is not a function, got undefined

i have been researching about this question and i found it has to be some syntax error. As i am new with Angular, i have been trying for quite some time now to locate the mistake, but with no success.

If somebody can help me, i will be very grateful, or maybe, if it is something else i am doing wrong:

angular.module('app-praiana', ['ionic', 'ngCordova'])

    .run(function ($ionicPlatform) {
        $ionicPlatform.ready(function () {
            // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
            // for form inputs)
            if (window.cordova && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            }
            if (window.StatusBar) {
                StatusBar.styleDefault();
            }
        });
    })

    .config(['$httpProvider', function ($httpProvider) {
            $httpProvider.defaults.useXDomain = true;
            delete $httpProvider.defaults.headers.common['X-Requested-With'];
        }])

    .config(function ($stateProvider, $urlRouterProvider) {

        $urlRouterProvider.otherwise('/inicio');


        $stateProvider.state('inicio-state', {
            url: '/inicio',
            views: {
                'inicio': {
                    templateUrl: 'templates/home.html',
                }
            }
        })

        $stateProvider.state('termos-state', {
            url: '/termos',
            views: {
                'termos': {
                    templateUrl: 'templates/termos.html'
                }
            }
        })

    });

angular.module('app-praiana.controllers', [])
    .controller('InicioController', function($scope){
        alert(1);
    });

EDIT:

the error happens at first sight, this is it:

Error: [ng:areq] Argument 'InicioController' is not a function, got undefined http://errors.angularjs.org/1.3.6/ng/areq?p0=InicioController&p1=not%20a%20function%2C%20got%20undefined at REGEX_STRING_REGEXP (ionic.bundle.js:7888) at assertArg (ionic.bundle.js:9389) at assertArgFn (ionic.bundle.js:9399) at ionic.bundle.js:16224 at ionic.bundle.js:15401 at forEach (ionic.bundle.js:8155) at nodeLinkFn (ionic.bundle.js:15388) at compositeLinkFn (ionic.bundle.js:14887) at nodeLinkFn (ionic.bundle.js:15526) at compositeLinkFn (ionic.bundle.js:14887)

like image 967
Fernando Ferrari Avatar asked Oct 28 '25 10:10

Fernando Ferrari


1 Answers

Your module app-praiana needs to have access to the app-praiana.controllers module in order to use its initioController.

First define the controller module, and then to declare your main module do:

angular.module('app-praiana', ['ionic', 'ngCordova', 'app-praiana.controllers'])
like image 182
floribon Avatar answered Oct 30 '25 00:10

floribon