我爲我的公司會計生成一個應用程序。 我列出了一個帳戶的所有操作,從一個ng-repeat的json。 吳重複工作偉大的,但問題是:角度ng-repeat:過濾器在symfony樹枝視圖中不起作用
我想爲操作的名稱添加過濾器的輸入。 該過濾器不起作用,並經過大量的搜索,我不明白爲什麼。
我app.js的代碼(角):
//app.js
var app = angular.module('app', [], function($interpolateProvider){
$interpolateProvider.startSymbol('<%');
$interpolateProvider.endSymbol('%>');
});
app.controller('MainController', function ($scope, Account) {
$scope.ops = {};
$scope.showOps = function(account_id) {
Account.get(account_id)
.success(function(data){
$scope.ops = data;
})
.error(function(data){
console.log(data);
});
}
})
app.factory('Account', function($http){
return {
get : function(account_id) {
return $http.get('/api/operations/' + account_id);
}
}
});
和代碼我的樹枝模板:
{% block body -%}
<div data-ng-init="showOps({{ entity.id }});">
<div class="account-head">
<h1>Compte</h1>
{{ form(delete_form) }}
</div>
<div class="panel-body">
<ul class="list-group">
<li class="list-group-item">
<span class="account-name">{{ entity.name }}</span>
<span class="account-actions">
<a class="btn btn-default btn-sm" href="{{ path('account_edit', { 'id': entity.id }) }}">Editer</a>
</span>
</li>
</ul>
</div>
<input placeholder="Search" data-ng-model="query.name" ng-disabled="isDisabled" type="text">
<div data-ng-repeat="op in ops | filter: query">
<p><% op.type %></p>
<p><% op.name %></p>
<p><% op.montant %></p>
<hr>
</div>
</div>
{% endblock %}
這應該過濾結果當輸入變化 的值(例如由我:http://chalasr.github.io/#/works) 但我沒有任何反應,當我寫入輸入。 我已經tryed一些型動物過濾器,如:
<div data-ng-repeat="op in ops | filter: {name: someNameInResult}">
<div data-ng-repeat="op in ops | filter: {query: query}">
但它一點兒也不作品! 如果你能幫助我,請提前致謝!
Thans爲您的答案,但它是行不通的,沒有反應。 我不明白這個問題:'( – chalasr 2015-04-04 20:46:08
你能發表一個ng-repeat迭代的數據的例子嗎?那個ng-repeat是否在沒有任何過濾器的情況下工作? – cheekybastard 2015-04-04 23:48:49