Open In App

AngularJS angular.bootstrap() Function

The angular.bootstrap() Function in AngularJS is a functional component in the Core ng module which is used to start up an Angular application manually, it provides more control over the initialization of the application. 

Syntax:



angular.bootstrap(element, [modules], [config]);

Parameter Values:

Example 1: This example describes the usage of the angular.bootstrap() Function in AngularJS.






<!DOCTYPE html>
<html>
  
<head>
    <title>angular.bootstrap() Function</title>
    <script src=
    </script>
    <style>
        .id {
            font-size: 1.5em;
            color: green;
        }
    </style>
</head>
  
<body ng-app="app" style="text-align:Center">
    <h1 style="color:green">GeeksforGeeks</h1>
    <h2>angular.bootstrap()</h2>
    <div ng-controller="geek">
        <span class="id">{{name}}</span>
        is the computer science portal for geeks.
    </div>
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', 
        function ($scope) {
            $scope.name = "GeeksforGeeks";
        }]);
        angular.bootstrap(document, ['app']);
    </script>
</body>
  
</html>

Output:

Example 2: This example describes the usage of the angular.bootstrap() Function in AngularJS by specifying the radio button.




<!DOCTYPE html>
<html>
  
<head>
    <title>angular.bootstrap() Function</title>
    <script src=
    </script>
</head>
  
<body ng-app="app" style="text-align:Center">
    <h1 style="color:green">
        GeeksforGeeks
    </h1>
      
    <h2>angular.bootstrap()</h2>
      
    <div ng-controller="geek">
        <div class="col-md-3 well" 
            ng-init="count=0"> Male:
            <input type="radio" ng-model="gender" 
            value="Male" 
            ng-change="layout(gender)" /> Female:
            <input type="radio" ng-model="gender" 
            value="Female" ng-change="layout(gender)" />
            <pre>
                <b>You selected:</b> {{result}} 
            </pre>
        </div>
    </div>
  
    <script>
        var app = angular.module("app", []);
        app.controller('geek', ['$scope', 
        function ($scope) {
            $scope.layout = function (gender) {
                $scope.result = gender;
            }
        }]);
        angular.bootstrap(document, ['app']);
    </script>
</body>
  
</html>

Output:

 


Article Tags :