The 'ng-repeat' limitTo filter won't work unless you remove the ng-if='true' attribute or put the <ul> list inside div element.
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp" ng-controller="namesCtrl">
<div ng-if='true'>
<p>Type a letter in the input field:</p>
<p><input type="number" ng-model="test"></p>
</div>
<ul>
<li ng-repeat="x in names | limitTo:test">
{{ x }}
</li>
</ul>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>
<p>The list will only consists of names matching the filter.</p>
</body>
</html>
@reference_1_w3schools
@reference_2_youtube
@reference_3_itfashion4u
How to connect one model variable to mutiple html elements using angularjs data binding?
No comments:
Post a Comment