Angular 中的 Ng-repeat 绑定到对象 {{ key.value }} 中的 HTML 模板
Ng-repeat in Angular bind to HTML template in object {{ key.value }}
我试图在页面标记中表示的服务中有一个对象。值得注意的是,对象中的 description
键存储了具有相关描述的 HTML 文件的本地地址。
这是我引用的对象:
service.content = [
{
id: 'bootstrap-grid',
title: 'The Complete Basics of the Bootstrap 3 Grid',
type: 'article',
date: 'February 28, 2015',
description: 'articles/partial/BootstrapGrid/description.html',
pathToHTML: 'articles/partial/BootstrapGrid/BootstrapGrid.html',
ratingArr: [],
updated: null,
},
{
id: 'HTMLConverter',
title: 'Blog-friendly HTML Converter',
type: 'resource',
date: 'March 6, 2015',
description: 'components/HTMLconverter/description.html',
pathToHTML: 'components/HTMLconverter/friendlyHTML.html',
ratingArr: [],
updated: null,
}
];
这是我尝试使用的标记。查看评论以查明问题。
<div class="global-container" ng-controller="HomeCtrl">
<h1>New Content</h1>
<span ng-repeat="post in posts">
<h1>
{{ post.title }}
</h1>
<div>
{{ post.date }}
</div>
<div class="post-title">
<a ui-sref="post({ id: post.id })">
{{ post.title }}
</a>
</div>
<!-- How can I get this to display the contents of the local html file address at this location? -->
{{ post.description }}
<a ui-sref="post({ id: post.id })">
Read Article
</a>
</span>
</div>
我尝试了 ng-include
但没有成功。
<ng-include src={{ post.description }}></ng-include>
我也试过创建一个指令,但是模板 URL 不包括当前的词法范围。我在这里有什么选择?
尝试
<ng-include src="post.description"></ng-include>
我试图在页面标记中表示的服务中有一个对象。值得注意的是,对象中的 description
键存储了具有相关描述的 HTML 文件的本地地址。
这是我引用的对象:
service.content = [
{
id: 'bootstrap-grid',
title: 'The Complete Basics of the Bootstrap 3 Grid',
type: 'article',
date: 'February 28, 2015',
description: 'articles/partial/BootstrapGrid/description.html',
pathToHTML: 'articles/partial/BootstrapGrid/BootstrapGrid.html',
ratingArr: [],
updated: null,
},
{
id: 'HTMLConverter',
title: 'Blog-friendly HTML Converter',
type: 'resource',
date: 'March 6, 2015',
description: 'components/HTMLconverter/description.html',
pathToHTML: 'components/HTMLconverter/friendlyHTML.html',
ratingArr: [],
updated: null,
}
];
这是我尝试使用的标记。查看评论以查明问题。
<div class="global-container" ng-controller="HomeCtrl">
<h1>New Content</h1>
<span ng-repeat="post in posts">
<h1>
{{ post.title }}
</h1>
<div>
{{ post.date }}
</div>
<div class="post-title">
<a ui-sref="post({ id: post.id })">
{{ post.title }}
</a>
</div>
<!-- How can I get this to display the contents of the local html file address at this location? -->
{{ post.description }}
<a ui-sref="post({ id: post.id })">
Read Article
</a>
</span>
</div>
我尝试了 ng-include
但没有成功。
<ng-include src={{ post.description }}></ng-include>
我也试过创建一个指令,但是模板 URL 不包括当前的词法范围。我在这里有什么选择?
尝试
<ng-include src="post.description"></ng-include>