angularjs-by-example icon indicating copy to clipboard operation
angularjs-by-example copied to clipboard

have to error when i create 3 controller

Open ttson24 opened this issue 9 years ago • 5 comments

hi you. when i create 3 controller is

angular.module('app.core', [])
    .controller('WhatsOnController', function($scope) {
        var vm = this;
        vm.title="This is title of what's on page";
    });

and

angular.module('app.core', [])
    .controller('MyShowsController', function($scope) {
        var vm = this;
        vm.title="This is title of my show page";
    });

and

angular.module('app.core', [])
    .controller('SearchController', function($scope) {
        var vm = this;

    });

i have route.js

angular.module('app.routes',['ngRoute']).config(routes);

function routes($routeProvider){
    $routeProvider
    .when('/',{
        templateUrl:'sections/whats-on/whats-on.tpl.html',
        controller:'WhatsOnController as whatsOn' 
    })
    .when('/my-shows',{
        templateUrl:'sections/my-shows/my-shows.tpl.html',
        controller:'MyShowsController as myShows'  
    })
    .when('/search',{
        templateUrl:'sections/search/search.tpl.html',
        controller:'SearchController as search' 
    }) 
    .otherwise({
        redirectTo:'/'
    })
}

the first controlller run: ok but second and 3th have to error: Argument 'MyShowsController' is not a

what is should i do?

ttson24 avatar May 03 '16 17:05 ttson24

Looks correct, did you add all your controllers in index.html?

jerry84 avatar May 16 '16 14:05 jerry84

Incase anybody stumbles upon this old thread. In the above example the app.core module is being created three times with angular.module('app.core', []). To add a controller to a module without creating it, simply remove the [], so angular.module('app.core').controller('MyShowsController') would do it.

RevillWeb avatar Mar 21 '17 07:03 RevillWeb

I am having error like while start the server :Local workspace file ('angular.json') could not be found. Error: Local workspace file ('angular.json') could not be found.

ravik1086 avatar May 07 '18 11:05 ravik1086

can you please explain and how can I correct it????? @RevillWeb

ravik1086 avatar May 07 '18 11:05 ravik1086

@ravik1086 It seems like you're using Angular not AngularJS

pankajparkar avatar Nov 12 '19 21:11 pankajparkar