Q: I'm trying to limit the number of displayed numbers in ng-repeat in html Angular novice and working through a fibonacci sequence app. I would like to only ng-repeat/display the current number in the sequence instead of having all of the numbers stack up in the html page. Should I use a directive instead or is limitTo the solution to dynamically display only one number each time the button is clicked? I looked for other answers, but none really fit my problem. Thanks for any help!
Here is my code so far:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Fibonacci</title>
<link rel="stylesheet" href="styles.css">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">

</head>
<body ng-app="fib" ng-controller="nextFibCtrl">

<h2 ng-repeat="result in results track by $index" | "limitTo: 1"> {{ result }} 
</h2>

<div>
<button type="button" class="reset" ng-click="clear()">RESET</button>
<button type="button" class="next" ng-click="nextNum()">NEXT FIB</button>
</div>

<script src = 
 "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.12/angular.js" >
</script>
<script src="script.js"></script>
</body>
</html>

My script file:
 var app = angular.module('fib', []);

 app.controller('nextFibCtrl', function($scope,){

 $scope.results = [0, 1];

 $scope.nextNum = function(){

     $scope.currentInt = $scope.results.length -1;

     $scope.nextInt = $scope.results[$scope.currentInt] +

     $scope.results[$scope.currentInt -1];

     $scope.results.push($scope.nextInt);

  }

      $scope.clear = function(){

      $scope.results = [0, 1];

  }

  });


A: You don't need ng-repeat. Just initialise and reference nextInt:
<h2>{{nextInt}}
</h2>

In your script:
$scope.nextInt = 1;

Or alternatively, just:
<h2>{{results[results.length - 1]}}</h2>


A: The issue in your code are quotes, so instead of this:
<h2 ng-repeat="result in results track by $index" | "limitTo: 1"> {{ result }} 
</h2>

Do this:
<h2 ng-repeat="result in results track by $index" | limitTo:1> {{ result }} 
</h2>

But, considering that you want to display only one value, and you already have that value bound to the scope, just change the code to this:
<h2> {{ $scope.nextInt }} </h2>

I hope it helps
