Professional Documents
Culture Documents
subject code:202046701
Unit-3
Example
<div ng-app="myApp" ng-controller="myCtrl">
{{ firstName + " " + lastName }}
</div>
<script>
app.controller("myCtrl", function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>
Adding a Directive
<script>
var app = angular.module("myApp", []);
app.directive("w3TestDirective", function() {
return {
template : "I was made in a directive constructor!"
};
});
</script>
AngularJS in build Directives
Directive Description
ng-app Defines the root element of an
application.
ng-bind Binds the content of an HTML element
to application data.
ng-blur Specifies a behavior on blur events.
ng-change Specifies an expression to evaluate
when content is being changed by the
user.
ng-checked Specifies if an element is checked or
not.
ng-click Specifies an expression to evaluate
when an element is being clicked.