javascript - UIRouter - Dynamically change ui-view attribute -


i dynamically change ui-view attribute such each time attribute changes, view changes too...

i use multiple views follow:

$stateprovider.state('main',         {url: "/main",             views: {                 '': { templateurl: "partials/main", controller: "mainctrl" },                 'clients@main': {templateurl: "partials/client-list", controller: "clientlistctrl"},                 'impexp@main': {templateurl: "partials/imp-exp", controller: "impexpctrl"}             }         }     ); 

in mainctrl define $scope variable follow:

$scope.main_view = 'clients'; 

and html/jade:

div(ng-attr-ui-view='{{ main_view }}' 

the problem when change dynamically $scope.main_view, view doesn't change.

is possible dynamically change ui-view? if is, how?

stateprovider (possibly app.js)

  $stateprovider     .state('main', {       url: "/main",       templateurl: "partials/main.html",       controller: 'mainctrl'     })     .state('main.substate', {       url: "/", // inherits /main parent state       templateurl: "partials/client-list.html",       controller: 'clientlistctrl',     }); 

any template loaded <div ui-view>

html example:

<!-- add site or application content here --> <div ng-include="'../views/main-nav.html'" ng-controller="navctrl"></div>  <div id="main" ui-view=""></div><!-- end #main -->  <div ng-include="'../views/footer.html'"></div> 

events trigger state change:

<a ui-sref="main.substate">changes out template , controller</a>  <span ng-click="$state.go('main.substate')">clicking change template</span> 

checkout ui-router $state docs.


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -