change angular ui-view inside ng-repeat

人走茶凉 提交于 2019-12-22 11:26:31

问题


I am using multiple named ui-views in a single controller. Everything is working as spected when name the ui-view in the html file with this code:

<div class="box"> 
  <div ui-view="selector"></div>  

  <div ui-view="widget1"></div>
  <div ui-view="widget2"></div>
  <div ui-view="widget3"></div>
  <div ui-view="widget4"></div>
</div>

But when I want to load dynamically some of those views with a ng-repeat it does not update the information.

<div class="widgets">
  <div class="widget-container" ng-repeat="widget in widgets">
    <div ui-view="{{widget}}"></div>
  </div>
</div>

How could I load ui-views from my ng-repeat?


回答1:


This hadn't been answered so i decided to go ahead and show how to do it. Unfortunately for some reason the attempt in the question didn't work but what you can do is link to a function between curly brackets and return the string of the view you want. For instance the controller would look like this:

$scope.groups = ['main','cases', 'models']; $scope.pickView = function(index){ return $scope.groups[index]; };



来源:https://stackoverflow.com/questions/17305805/change-angular-ui-view-inside-ng-repeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!