AngularJs,是否可以插入从$ scope数组中获取的数据?

时间:2016-03-04 17:27:27

标签: html angularjs

我有这个javascript代码:

app.controller('Ctrl',[ '$scope', function ($scope){
    $scope.poems =[
                    {title:"title1", author:"author1", file:"URLfile1"},
                    {title:"title2", author:"author2", file:"URLfile2"},
                    {title:"title3", author:"author3", file:"URLfile3"}
                    ];
}]);

进入html我想做类似的事情:

<div ng-repeat ="poem in poems">
   <h1>{{poem.title}}</h1>
   <p>{{poem.author}}</p>
   <div ng-include="{{poem.file}}"></div>
</div>

但这似乎不起作用。 你有什么建议吗?

2 个答案:

答案 0 :(得分:0)

然后你可以试试这个

<div ng-include src="{{poem.file}}"></div>

这可能会奏效。

答案 1 :(得分:0)

解决方案是

<div ng-include src="poem.file"></div>

没有括号