I'd like to init a filtered list with angularjs, I don't know how to access to ng-init variables...
Edit #1 :
app.controller("AgreementsController", function($scope, $http, $filter) {
$scope.agreements = [];
$http.get('/api/agreement').success(function(data, status, headers, config) {
$scope.agreements = data.agreements;
$scope.filteredAgreements = $filter('filter')($scope.agreements,
{number: $scope.search});
});
<tbody ng-init="filteredAgreements = (agreements | filter:{number:search})">
<tr ng-repeat="agreement in agreements | filter:{number:search} | limitTo:5">
<td>{{agreement.number}}</td>
</tr>
</tbody>
{{filteredAgreements.length}} <!-- 291 even if I put "65" into the search -->
AgreementsControllerto be found in the DOM in relation to the HTML you posted?ng-init... My controller well in the dom but not in the post ;)ngInit.ngInitevaluates an expression in the current scope. If that's the same scope the controller operates on then the controller can access it via the scope.filteredAgreements?agreementsis empty whenngInitis run. ThereforefilteredAgreementsis empty, too. One has to wonder why you usengInitanyway.