[英]Two ui-view in the same page AngularJs
I'm new in AngularJs and I have a problem,I have two ui-view in the same page, and when push in the one button for example for show the view goals, appear the form goal in the ui-view 1 and also in the second ui-view at the same time,I worked with states.I don't know how to do for when push one button only show the form belonging to one ui-view, 我是AngularJs的新手,我有一个问题,我在同一页面中有两个ui视图,例如当按下一个按钮以显示视图目标时,在ui-view 1中也会出现表单目标在同一时间的第二个ui视图中,我使用了states。我不知道该怎么做,当按下一个按钮仅显示属于一个ui视图的表单时,
look my source: 看我的资料:
HTML 的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>
Controllerjs: Controller.js:
$scope.go = function(route){ $state.go(route); };
RouteJs: RouteJs:
.state('projectShow.milestones.goals', {
templateUrl: '../assets/projects/formulario.html', })
.state('projectShow.milestones.reports',{
templateUrl: '../assets/reports/formularioReport.html' })
Regards! 问候! and thanks for your time !
多谢您的宝贵时间!
Since you have multiple ui-view directives you need to give each one a name so you can target them individually. 由于您有多个ui-view指令,因此需要为每个指令指定一个名称,以便可以分别定位它们。
According to the ui-router wiki 根据ui-router Wiki
You can only have one unnamed view within any template (or root html)
任何模板(或根html)中只能有一个未命名的视图
<!-- Unnamed -->
<div ui-view></div>
<!-- Named -->
<div ui-view="viewName"></div>
There are more details on how to setup ui-router & ui-view here. 这里有更多关于如何设置ui-router和ui-view的细节。 https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view
https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.