- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
是否可以使用 ui-view 使用 2 个或更多 html 文件制作某些东西?我需要它是这样的:
我尝试在 plinker 上做一些工作,但看起来我显然不理解概念。我读过一个嵌套的 ui-vew 教程,但他们简单地制作了一个 index.html 并在那里放置了多个 ui-view,但我需要多个 .html 文件。
test.html 只是一个包含一些应该显示在主标题下的文本的文件
index.html 看起来像这样
<html ng-app="MyApp">
<head>
<link href="stylesheets/style.css" rel="stylesheet">
</head>
<body>
<h4>
This should be Master header
</h4>
<div ui-view></div>
<script data-require="angular.js@*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script>
<script data-require="ui-router@*" data-semver="0.2.10" src="https://rawgit.com/angular-ui/ui-router/0.2.10/release/angular-ui-router.js"></script>
<script src="app.js"></script>
<script src="controllers/main.js"></script>
</body>
</html>
这是 app.html
<head>
<link href="stylesheets/style.css" rel="stylesheet">
</head>
<body>
<h4>
This should be Sub master header
</h4>
<div ui-view></div>
</body>
app.js 是用伪代码编写的,展示了我希望它如何工作,因为我显然不知道如何让它工作
angular.module('MyApp', [
'ui.router'
])
.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('index', {
templateUrl: 'index.html',
controller: 'IndexCtrl'
})
.state('index.test', {
url: '/',
templateUrl: 'test.html',
controller: 'TestCtrl'
})
.state('app', {
templateUrl: 'app.html',
controller: 'AppController'
})
.state('app.test2', {
url: '/test2',
templateUrl: 'test2.html',
controller: 'Test2Controller'
})
})
test2.html 只是一个文本。
最佳答案
我不确定我是否 100% 理解您的目标,但已更新 plunker ,展示了我们如何使用嵌套 View 。
首先,有一个显示嵌套的 $state 定义:
$stateProvider
.state('index', {
url: '/',
views: {
'@' : {
templateUrl: 'layout.html',
controller: 'IndexCtrl'
},
'top@index' : { templateUrl: 'tpl.top.html',},
'left@index' : { templateUrl: 'tpl.left.html',},
'main@index' : { templateUrl: 'tpl.main.html',},
},
})
.state('index.list', {
url: '/list',
templateUrl: 'list.html',
controller: 'ListCtrl'
})
.state('index.list.detail', {
url: '/:id',
views: {
'detail@index' : {
templateUrl: 'detail.html',
controller: 'DetailCtrl'
},
},
})
这是索引核心模板layout.html
:
<div>
<section class="top">
<div ui-view="top"></div>
</section>
<section class="middle">
<section class="left">
<div ui-view="left"></div>
</section>
<section class="main">
<div ui-view="main"></div>
</section>
</section>
</div>
它是如何运作的?
我们可以看到tpl.top.html
的内容
<div>
This is a tpl.top.html<br />
<a ui-sref="index">index</a>
<a ui-sref="index.list">index.list</a><br />
</div>
确实有一些导航到索引或 ListView 。 ListView 将被注入(inject)到 tpl.left.html 中,如下所示:
<div>
This is a tpl.left.html
<h4>place for list</h4>
<div ui-view=""></div>
</div>
因为 View 目标未命名 <div ui-view=""></div>
,我们可以这样定义列表 $state:
.state('index.list', {
url: '/list',
templateUrl: 'list.html',
controller: 'ListCtrl'
})
我们可以看到,我们的目标是未命名的索引(根)状态 View anchor 。但对于细节,我们确实使用了不同的技术:
这是 tpl.main.html 的内容:
<div>
This is a tpl.main.html
<h4>place for detail</h4>
<div ui-view="detail"></div>
</div>
在这种情况下, View 的 anchor 命名为:ui-view="detail",这就是为什么我们必须像这样定义 detail 状态:
.state('index.list.detail', {
url: '/:id',
views: {
'detail@index' : {
templateUrl: 'detail.html',
controller: 'DetailCtrl'
},
},
})
我们可以看到,因为父 View 不是我们状态的目标(祖父索引是目标),我们必须使用绝对命名:<强> 'detail@index'
三。 View Names - Relative vs. Absolute Names
来自文档的小引用:
Behind the scenes, every view gets assigned an absolute name that follows a scheme of
viewname@statename
, where viewname is the name used in the view directive and state name is the state's absolute name, e.g. contact.item. You can also choose to write your view names in the absolute syntax.
总结:
所以,这个例子是关于它的——关于 ui-router
的几乎所有基本特征。 .我们在这里展示了如何使用嵌套、 View 命名(绝对/相对)以及如何为一种状态使用多个 View (索引状态定义)
请注意所有的 Action here (单击顶部部分的 inex.html,然后尝试选择一些详细信息)
关于javascript - ui-router 中的多个 ui-view html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25349170/
情况我想使用 ui-date 在我的应用程序中设置/编辑日期。我使用最新稳定版本的 Angular、Angular-UI、JQuery-UI 等。 问题一旦使用日期选择器选择了日期,我的模型中的日期将
编辑: jQuery UI 可选择小部件内置了一个回调,stop,我需要知道如何以编程方式触发此事件。 (措辞不佳)我已将事件监听器附加到 jQuery UI Selectable Widget 。如
我正在尝试建立一个下一个JS与尾风用户界面提供的反应组件的网络应用程序。顺风用户界面是在幕后使用无头用户界面。。默认情况下,Next JS将构建服务器端组件,除非您在页面顶部添加“使用客户端”。不幸的
我正在尝试建立一个下一个JS与尾风用户界面提供的反应组件的网络应用程序。顺风用户界面是在幕后使用无头用户界面。。默认情况下,Next JS将构建服务器端组件,除非您在页面顶部添加“使用客户端”。不幸的
我正在尝试应用这个 SlickGrid 示例: http://mleibman.github.com/SlickGrid/examples/example4-model.html 到我自己的网络项目。
我想整理我的 Schemas为我的实体类生成,DTO 类位于 Springdoc ui . 我可以对 tags 进行排序和 operations通过以下配置 yml文件,但我的模式不是按排序顺序排列的
有谁知道阻止 ui-sref 重新加载状态的方法吗? 我无法通过“$stateChangeStart”事件执行此操作,因为 ui-sref 仅更改参数而不更改状态名称。 我的左边是书单,左边是书的详细
我正在 jquery ui 对话框中使用 jquery ui 自动完成小部件。当我输入搜索文本时,文本框缩进(ui-autocomplet-loading)但不显示任何建议。 var availabl
我正在尝试将 Kendo UI MVVM 框架与 Kendo UI 拖放机制结合使用;但我很难找到如何将数据从 draggable 对象中删除。 我的代码是这样的...... var viewMode
Kendo UI Web 和 Kendo UI Core 之间有什么区别 https://www.nuget.org/packages/KendoUIWeb http://www.nuget.org/
我正在尝试将 Kendo UI MVVM 框架与 Kendo UI 拖放机制结合使用;但是我很难找到如何从 draggable 对象中删除数据。 我的代码是这样的…… var viewModel =
使用 Angular JS - UI 路由器,我需要从我的父 View project.details 到我的 subview project.details.tasks 进行通信。我的 subvie
KendoUI 版本 2013.3.1119使用 Kendo MVVM 我有一个我构建的颜色选择器,它使用平面颜色选择器和使用调色板的颜色选择器。它们都可以正常运行,但平面颜色选择器的布局已关闭, s
我在非 UI 线程上,我需要创建并显示一个 SaveDialog。但是当我尝试显示它时:.ShowDialog() 我得到: "An unhandled exception of type 'Syst
我正在试验 jquery-ui 并查看和克隆一些示例。在一个示例(自动完成的组合框)中,我看到一个带有 ui-widget 类的 anchor (a) 元素,它与包含的 css 文件中的 .ui-wi
我需要返回一个 UI 列表,我用这个方法: getList(): Observable { return this.httpClient.get("/api/listui").pipe
我有 ui-grids在 angular-ui-tabs ,它们位于 ng-if 中以避免呈现问题。如果有更多数据并且网格进入滚动模式,则单击选项卡时数据会完全消失。我相信这是一个 ui-grids-
这似乎是一个通用的问题,与其他几个 React 开源框架相比,我真的很喜欢 Material ui 的可扩展性。 问题 “@material-ui/core”和“@material-ui/lab”中的
我有一个根页面(index.html),带有侧边栏(“菜单”)和主要内容 div(“主”),因此有两个 ui-view div - 一个称为“菜单”,一个称为“主”。 当主要内容区域有网站列表 (/s
有人在http://jsfiddle.net/hKYWr/上整理了一个很好的 fiddle 。关于使用 angular-ui 和 jqueryui sortable 来获得良好的可排序效果。 如何在两
我是一名优秀的程序员,十分优秀!