I'm starting to learn with AngularJS. In a simple function, I need to do the factorial of a number using AngularJS, but I can not return the result on the screen (HTML page). Could someone help me?
<!DOCTYPE html>
<html ng-app="fatorialApp">
<head>
<meta charset="UTF-8" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script></head><bodyng-controller="fatorialController">
<div>
<label>Número:</label>
<input type="text" ng-model="numero" placeholder="Calcular o fatorial">
<hr>
<h1>{{ resultado }}</h1>
</div>
<script>
var app = angular.module('fatorialApp', []);
app.controller('fatorialController', function($scope) {
$scope.resultado = function() {
var resultadoDoFatorial = 1;
for (var i = 1; i <= $scope.numero; i++) {
resultadoDoFatorial = resultadoDoFatorial * i;
}
return resultadoDoFatorial;
}
});
</script>
</body>
</html>