javascript - Change controller on the fly -


i have 3 controllers , 2 divs in main angular application. let's left , right div , controller a, b, , c. @ start, set left div controller , right div controller b. want add button change left div use controller c , run it. possible? have stuck 3 days. think it's simple problem because it's matter of changing controller , re-run new controller.

i suggest try angularui router: https://github.com/angular-ui/ui-router

in case have 2 states, both have same template, different controllers.

example:

myapp.config(function($stateprovider) {   $stateprovider     .state('route1', {       url: "/route1",       views: {         "viewa": {            templateurl: "templates/a.html",            controller: "acontroller"         },         "viewb": {            templateurl: "templates/b.html",            controller: "bcontroller"         }       }     })     .state('route2', {       url: "/route2",                 views: {         "viewa": {            templateurl: "templates/a.html",            controller: "ccontroller"         },         "viewb": {            templateurl: "templates/b.html",            controller: "bcontroller"         }       }     }) }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -