-
-
Save bakkiraju/638c78907e54b37c3b6330cde57ce64a to your computer and use it in GitHub Desktop.
MultiController-AngularJS example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> | |
<body> | |
<div ng-app="myApp"> | |
<div ng-controller="personCtrl"> | |
First Name: <input type="text" ng-model="firstName"><br> | |
Last Name: <input type="text" ng-model="lastName"><br> | |
<br> | |
Full Name: {{fullName()}} | |
</div> | |
<br> | |
<br> | |
<div ng-controller="otherCtrl"> | |
First Name: <input type="text" ng-model="firstName"><br> | |
Last Name: <input type="text" ng-model="lastName"><br> | |
<br> | |
Full Name: {{fullName()}} | |
</div> | |
<br> | |
<br> | |
<div ng-controller="anotherCtrl"> | |
First Name: <input type="text" ng-model="firstName"><br> | |
Last Name: <input type="text" ng-model="lastName"><br> | |
<br> | |
Full Name: {{fullName()}} | |
</div> | |
</div> | |
<script> | |
var app = angular.module('myApp', []); | |
app.controller('personCtrl', function($scope) { | |
$scope.firstName = "John"; | |
$scope.lastName = "Doe"; | |
$scope.fullName = function() { | |
return $scope.firstName + " " + $scope.lastName; | |
}; | |
}); | |
app.controller('otherCtrl', function($scope) { | |
$scope.firstName = "James"; | |
$scope.lastName = "smith"; | |
$scope.fullName = function() { | |
return $scope.firstName + " " + $scope.lastName; | |
}; | |
}); | |
app.controller('anotherCtrl', function($scope) { | |
$scope.firstName = "Bilahari"; | |
$scope.lastName = "Akkiraju"; | |
$scope.fullName = function() { | |
return $scope.lastName + " " + $scope.firstName; | |
}; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment