我是angularJS的新手。我已经使用html尝试了这些代码并且运行良好但是当我将此代码插入我的django应用程序时,我无法在我的桌面上获取任何数据
<script src="{% static "angularjs-1.4.3/angular.min.js" %}"></script>
<div ng-app="">
<div ng-init="friends = [{name:'John', phone:'555-1276'},
{name:'Mary', phone:'800-BIG-MARY'},
{name:'Mike', phone:'555-4321'},
{name:'Adam', phone:'555-5678'},
{name:'Julie', phone:'555-8765'},
{name:'Juliette', phone:'555-5678'}]"></div>
<label>Search: <input ng-model="searchText"></label>
<table border=" <script src="{% static "angularjs-1.4.3/angular.min.js" %}"></script>
<div ng-app="">
<div ng-init="friends = [{name:'John', phone:'555-1276'},
{name:'Mary', phone:'800-BIG-MARY'},
{name:'Mike', phone:'555-4321'},
{name:'Adam', phone:'555-5678'},
{name:'Julie', phone:'555-8765'},
{name:'Juliette', phone:'555-5678'}]"></div>
<label>Search: <input ng-model="searchText"></label>
<table border="1" id="searchTextResults">
<tr><th>Name</th><th>Phone</th></tr>
<tr ng-repeat="friend in friends | filter:searchText">
<td>{{ friend.name }}</td>
<td>{{ friend.phone }}</td>
</tr>
</div>
</table>1" id="searchTextResults">
<tr><th>Name</th><th>Phone</th></tr>
<tr ng-repeat="friend in friends | filter:searchText">
<td>{{ friend.name }}</td>
<td>{{ friend.phone }}</td>
</tr>
</div>
</table>
我相信我一定错误地使用了这种语法:
<tr ng-repeat="friend in friends | filter:searchText">
<td>{{ friend.name }}</td>
<td>{{ friend.phone }}</td>
</tr>
非常感谢你的帮助! :)
答案 0 :(得分:3)
您正在使用django模板中的Angular变量。 Django使用符号{{variable}}来渲染django变量。有两种解决方法:
{% verbatim %} <tr ng-repeat="friend in friends | filter:searchText"> <td>{{ friend.name }}</td> <td>{{ friend.phone }}</td> </tr> {% endverbatim %}