Many tutorials on AngularJS recommend using anonymous functions instead of normal functions, like function name(para1) {}. For example, take a look at this link: http://www.w3schools.com/angular/tryit.asp?filename=try_ng_controller_property
I tried changing to a normal function, but it didn't work. Can anyone provide guidance on this issue? Thank you.
<div ng-app="myApp" ng-controller="personCtrl as main">
First Name: <input type="text" ng-model="firstName"><br>
Last Name: <input type="text" ng-model="lastName"><br>
<br>
Full Name: {{main.fullName()}}
</div>
<script>
var app = angular.module('myApp', []);
app.controller('personCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
function fullName() {
return $scope.firstName + " " + $scope.lastName;
};
});
</script>