AngularJS Employee Controller
Enter first name:
Enter last name: You are entering: {{emp.fullName()}}
<html>
<head> <title>Angular JS Controller</title> </head> <body> <h2>AngularJS Employee Controller</h2> <div ng-app = "mainApp" ng-controller = "empController"> Enter first name: <input type = "text" ng-model = "emp.firstName"><br><br> Enter last name: <input type = "text" ng-model = "emp.lastName"><br> <br> You are entering: {{emp.fullName()}} </div> <script> var mainApp = angular.module("mainApp", []); mainApp.controller('empController', function($scope) { $scope.emp = { firstName: "aarif", lastName: "mohammad", fullName: function() { var empObject; empObject = $scope.emp; return empObject.firstName + "-> " + empObject.lastName; } }; }); </script> </body> </html> |