Search code examples
angularjsmean-stackng-controller

Is it possible to have more than one ng-controller for one templateUrl when using .when?


Is it possible to have more than one ng-controller for one templateUrl when using .when? I need three different ng-controllers and two factories for the same templateUrl. I know I can have many controllers, but I don't know how to with .when, and I need to use .when because I'm using nodejs and expressjs as well.


Solution

  • You can nest those 2 controllers inside one defined in .when in HTML template. So, your HTML template may look like-

    <div ng-controller="ctrl2">
        <div ng-controller="ctrl3">
        ...
        </div>
    </div>