I need to do a registration form page using angularjs and in this i need to show how many percentage have completed. I have more than 50 fields. How i can do this functionality in a simple way.
Here is the sample code. I don't know is this the good way of coding
HTML Code
<script src="angular/angular.js"></script>
<html ng-app="myapp" ng-controller='profileController'>
<form>
First name: <input type="text" name="firstname" ng-model="nameValue" ng-click="percentageCount()"/><br>
Last name: <input type="text" name="lastname" ng-model="lnameValue" ng-click="percentageCount()"/>
Age: <input type="text" name="age" ng-model="ageValue" ng-click="percentageCount()" />
Gender: <input type="text" name="gender" ng-model="genderValue" ng-click="percentageCount()"/>
City: <select name="txt_country" class="drop-down-box" id="country" ng-click="percentageCount()" ng-model="countryValue">
<option value="" selected="selected">Select Country</option>
<option value="United States">United States</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
</select>
</form>
<p>{{count}}% completed</p>
</html>
Script
<script>
var myapp = angular.module('myapp', []);
myapp.controller('profileController', function ($scope,$http)
{
$scope.count = 0;
$scope.percentageCount = function()
{
$scope.count =0;
if($scope.nameValue != null)
$scope.count = $scope.count+20;
if($scope.lnameValue != null)
$scope.count = $scope.count+20;
if($scope.ageValue != null)
$scope.count = $scope.count+20;
if($scope.genderValue != null)
$scope.count = $scope.count+20;
if($scope.countryValue != null)
$scope.count = $scope.count+20;
}
});
</script>
here I need to use lots of if condition.
In jquery we can do this using
$('input').on('change', function()
How i can do this in angularjs as a good way of coding
Thank you in advance.