How do you add two controllers to the same view in route angular

50 Views Asked by At

The part of the code I want to change is

    var profile = {
        name: "web.profile",
        parent: "web",
        url: "/profile",         
        title: "Profile",
        controller: 'controller1',
        controllerAs: 'profile'
        
    };

There is only one controller in use, and I want to use another one, but I get an error when I change my code like this:

    var profile = {
        name: "web.profile",
        parent: "web",
        url: "/profile",
        title: "Profile",
        controller: 'controller1',
        controller: 'controller2',
        controllerAs: 'profile'
        
    };
1

There are 1 best solutions below

0
James Drinkwater On

So, This isn't the way you should be structuring things. Each view should have only one controller. If you want more functionality, or you need to share information between controllers, investigate injecting a service into the controller.