javascript - 同一页面中的两个 ui-view AngularJs

标签 javascript html ruby angularjs

我是 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/

相关文章:

html - Telerik RadButton 更改选项卡/焦点/事件上的文本颜色

html - 如何将 ul 对齐到骨架中的中心?

javascript - 如何使本地 APNS 推送通知静音?

javascript - 删除 X 和 Y 轴上的标签并删除 X 轴上的最后一条网格线

html - 从 css 添加 title 属性

Ruby PATH 未正确设置

ruby - rvm 安装不工作 : "RVM is not a function"

ios - CocoaPods 不在 pod 安装时创建 Pods.xcconfig

javascript - 我们如何使用meteor restivus发布数据

javascript - 如何修复 : Save filtered lookup by current user and status in sharepoint online