I want to bind the full name = firstname + lastname.
I have seen this example in the w3 schools. But i am unable to understand it.
My question is how the function got called? It have any listeners?
Could someone please, shed some light on it, in detailed way. Sorry I am newbie..
My code is:
var application = angular.module('myTempApp', []);
application.controller('myController', function ($scope) {
$scope.myFirstName = "xxx";
$scope.myLastName = "yyy";
$scope.myFunction = function () {
alert('called');
$scope.myFullName = $scope.myFirstName + $scope.myLastName;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body>
<div ng-app="myTempApp" ng-controller="myController">
<input type="text" ng-model="myFirstName" />
<input type="text" ng-model="myLastName" />
<input type="text" ng-model="myFullName" ng-bind="myFullName" />
<br />
{{ myFunction() }}
<br/>
data ::: {{2+2}}
</div>
</body>
Thanks in advance.