Skip to content

have to error when i create 3 controller #2

Open

Description

@ttson24

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?

Activity

  1. jerry84 commented on May 16, 2016

    @jerry84

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

  2. RevillWeb commented on Mar 21, 2017

    @RevillWeb
    Owner

    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.

  3. ravik1086 commented on May 7, 2018

    @ravik1086

    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.

  4. ravik1086 commented on May 7, 2018

    @ravik1086

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

  5. pankajparkar commented on Nov 12, 2019

    @pankajparkar

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions