Alexe Bogdan
Web Developer, JavaScript Lover, User Experience Professional, working in the web and mobile application development industry.
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>Angular app</title>
<script src="bower_components/angular/angular.js"></script>
</head>
<body ng-controller="MyCtrl">
<p>Hello {{name}}!</p>
<input type="text" ng-model="name">
</body>
</html>
angular
.module('myApp', [])
.controller('MyCtrl', function($scope){
$scope.name = 'World';
});
First Name: <input type="text" ng-model="user.firstName" />
Last Name: <input type="text" ng-model="user.lastName" />
<ul>
<li ng-repeat="user in userList">
{{user.firstName}} {{user.lastName}}
</li>
</ul>
The $digest will loop trough the watchers list:
If the $scope is dirty, another $digest loop is triggered.
app.directive('click', function() {
return {
scope: {
name: '='
},
link: function(scope, element, attrs) {
element.on('click', function() {
scope.$apply(function() {
scope.name = 'new name';
});
});
}
}
});
By Alexe Bogdan
Angular Framework: Key Features & Data Binding;
Web Developer, JavaScript Lover, User Experience Professional, working in the web and mobile application development industry.