我是 AngularJs 的新手,我有一个问题,我在同一页面中有两个 ui-view,当按下一个按钮(例如显示 View 目标)时,在 ui-view 中出现表单目标1 并且同时在第二个 ui-view 中,我与状态一起工作。我不知道当按下一个按钮时只显示属于一个 ui-view 的表单时该怎么做,
看我的来源:
HTML
<button class="btn btn-success"
ng-click="go('projectShow.milestones.reports')">New Report</button>
<div ui-view class="crearreport"></div>
<button class="btn btn-success"
ng-click="go('projectShow.milestones.goals')">New Goals</button>
<div ui-view class="creargoal"></div>
Controller :
$scope.go = function(route){ $state.go(route); };
路由:
.state('projectShow.milestones.goals', {
templateUrl: '../assets/projects/formulario.html', })
.state('projectShow.milestones.reports',{
templateUrl: '../assets/reports/formularioReport.html' })
问候!感谢您的宝贵时间!
最佳答案
由于您有多个 ui-view 指令,您需要为每个指令命名,以便您可以单独定位它们。
根据 ui-router wiki
You can only have one unnamed view within any template (or root html)
<!-- Unnamed -->
<div ui-view></div>
<!-- Named -->
<div ui-view="viewName"></div>
这里有更多关于如何设置 ui-router 和 ui-view 的细节。 https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view
关于javascript - 同一页面中的两个 ui-view AngularJs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25798425/