Monday, 7 January 2019

AngularJS ng-app directive


AngularJS ng-app directive

ng-app directive define the start point of the any angular application. It specifies the root element of the application. any AngularJS application must define the root element using ng-app  to auto-bootstrap as an application.

<div ng-app="myCalculation" ng-controller="CalculationController">
        <p>Addition of number: {{a}} + {{b}} =  {{ a+b }}</p>
        <p>Substraction of number: {{a}} - {{b}} =  {{ a-b }}</p>
        <p>Multiplication of number: {{a}} * {{b}} =  {{ a*b }}</p>
        <p>Division of number: {{a}} / {{b}} =  {{ a/b }}</p>
</div>
<script>
        var myapp = angular.module('myCalculation', []);
        myapp.controller('CalculationController', function ($scope) {
            $scope.a = 20;
            $scope.b = 4
        });
</script>

Output:-


No comments:

Post a Comment