我正在尝试使用ng-repeat
来创建一个列表,但是我希望已经存在的列表项目可以使用Django进行渲染。
注意:我已将{[{ }]}
设置为我的AngularJS InterpolateProvider。
HTML示例
<ul ng-controller="ListController">
{% for item in existing_list %}
<li>
<span>{{item.firstName}}</span>
<span>{{item.lastName}}</span>
</li>
{% endfor %}
<li ng-repeat="item in items">
<span>{[{item.firstName}]}</span>
<span>{[{item.lastName}]}</span>
</li>
</ul>
现在,我想使用
ng-controller
来处理这些项目。
app.js
function ListController($scope){
$scope.items = [{firstName: "Bob", lastName: "Smith"}];
}
我的问题是,我该如何将由Django生成的预先存在的列表项添加到
$scope.items
中?