angular ng-route 找不到模板
angular ng-route doesn't find a template
Angular ng-route 未找到模板,但它包含在 Dom 中。我收到此错误:
http://localhost/template/recipes 加载资源失败:服务器返回状态 404(未找到)
在html中:
.
.
.
<div class="row">
<div class="col-lg-6">
<div ui-view>
loading...
</div>
</div>
</div>
</div>
<script type="text/ng-template" id="/template/recipes">
<div class="row">{{title}}<div>
</script>
routeConfig.js:
$urlRouterProvider.otherwise('/recipes');
$stateProvider.state('recipes', {
url: '/recipes',
templateUrl: '/template/recipes',
controller: 'recipesController'
});
有谁知道如何解决这个问题?
您忘记关闭模板中的 div 标签。这是工作 plnk.
<script type="text/ng-template" id="/template/recipes">
<div class="row">{{title}}</div>
</script>
编辑
我还更新了 plnk 以显示带和不带扩展名的模板名称。
Angular ng-route 未找到模板,但它包含在 Dom 中。我收到此错误:
http://localhost/template/recipes 加载资源失败:服务器返回状态 404(未找到)
在html中:
.
.
.
<div class="row">
<div class="col-lg-6">
<div ui-view>
loading...
</div>
</div>
</div>
</div>
<script type="text/ng-template" id="/template/recipes">
<div class="row">{{title}}<div>
</script>
routeConfig.js:
$urlRouterProvider.otherwise('/recipes');
$stateProvider.state('recipes', {
url: '/recipes',
templateUrl: '/template/recipes',
controller: 'recipesController'
});
有谁知道如何解决这个问题?
您忘记关闭模板中的 div 标签。这是工作 plnk.
<script type="text/ng-template" id="/template/recipes">
<div class="row">{{title}}</div>
</script>
编辑
我还更新了 plnk 以显示带和不带扩展名的模板名称。