javascript - ng-view 未显示在 index html 页面中
问题描述
我的目标是在网络应用程序上做路由页面。我写了两页:索引和主页。在索引页面中,有调用主页的 ng-view。但浏览器不显示任何主页。也许我写 script.js 是错误的......
索引.html:
<body ng-controller="productsCtrl">
<header ng-include="'header.html'"></header>
<div id="main">
<!-- angular templating -->
<!-- this is where content will be injected -->
<div ng-view>
</div>
</div>
</body>
脚本.js:
var app = angular.module('myApp', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/home', {
templateUrl: '../templates/home.html'
})
.otherwise({
redirectTo: '/home'
});
}]);
有人可以帮助男人解决这个问题。谢谢
解决方案
你必须使用 ng-app 指令
<body ng-app="myApp">
推荐阅读
- ios - swift:加载包含 300 张图像的数组
- wsdl - 在 OSB JDeveloper 12c 中更新业务服务
- azure-data-lake - 如何查询不同结构的文件?
- boto3 - 如果 source_list 中的项目存在于 target_list 中,则从 S3 存储桶中删除 s3 对象
- html - 边框图像出现在所有菜单项之间,但不在最后一项
- linux - 参数替换替换为交替 (OR) |
- racket - 如何在 Racket 中将输入读取为字符串
- reactjs - 离开页面时如何清除状态
- youtube - YouTube LiveStream API accessNotConfigured 错误
- android - 使用 AndroidX 生物识别最新版本进行身份验证会导致崩溃 [Android]