To control the flow of data AngularJS mainly relies on controllers. It is defined using ng-controller directive. Controller contain attributes, properties and functions.
<html>
<head>
<title>AngularJS Controllers</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
</head>
<body>
<h2>AngularJS Controllers</h2>
<div ng-app="ngApp" ng-controller="nameController">
First name: <input type="text" ng-model="name.firstName"><br><br>
Last name: <input type="text" ng-model="name.lastName"><br>
<br>
Full name: {{name.fullName()}}
</div>
<script>
var ngApp = angular.module("ngApp", []);
ngApp.controller('nameController', function($scope) {
$scope.name = {
firstName: "Mark",
lastName: "Taylor",
fullName: function() {
var nameObject;
nameObject = $scope.name;
return nameObject.firstName + " " + nameObject.lastName;
}
};
});
</script>
</body>
</html> Ask any conference organizer why their speaker lineup skews heavily male, and the answer is…
In the business world, there’s no such thing as a new idea. The best we…
Both of these work. Both are difficult. And anyone telling you one is obviously better…
Digital marketing naturally focuses on online spaces. Businesses invest in social media, SEO, email campaigns,…
Introduction There is an increasing need for full-stack developers because companies want people who can…
Classic Russian literature holds a quiet power that still shapes stories today. Its voice feels…