【发布时间】:2016-09-19 04:29:24
【问题描述】:
在 Angular 应用程序中,我需要在 B.html 中包含 A.html 及其控制器,而不需要复制 A.html 或 AController。
我在 A.html 中写了以下内容,但是没有用
<div ng-include src="src/html/v1/A.html"></div>
以下是应用的代码结构
src
├── html
│ ├── v1
│ │ ├── A.html
│ │ ├── B.html
├── index.coffee
├── index.html
├── js
│ ├── controllers
│ │ ├── v1
│ │ │ ├── AController.js
| │ │ ├── BController.js
└── sass
├── v1
以下是 index.coffee 包含的内容 -
$routeProvider
.when("/",
{
templateUrl: "src/html/v1/A.html",
title: "A"
controller: "AController"
})
.when("/A",
{
templateUrl: "src/html/v1/A.html",
title: "A"
controller: "AController"
})
.when("/B",
{
templateUrl: "src/html/v1/B.html",
title: "B"
controller: "BController"
})
.otherwise({ redirectTo: "/" })
请建议我在这里缺少什么。
PS:这个问题的答案可能是许多其他类似问题的答案,但我一开始找不到答案。对这个问题的支持清楚地表明它具有相关性。
【问题讨论】:
标签: javascript html angularjs angularjs-ng-include