1. Question:How AngularJS handle the security? 

    Answer
    AngularJS provide following built-in protection from basic security holes:
    1. Prevent HTML injection attacks.
    2. Prevent Cross-Site-Scripting (CSS) attacks.
    3. Prevent XSRF protection for server side communication.
    
    Also, AngularJS is designed to be compatible with other security measures like Content Security Policy (CSP), HTTPS (SSL/TLS) and server-side authentication and authorization that greatly reduce the possible attacks.

    1. Report
  2. Question:What are Modules in AngularJS? 

    Answer
    AngularJS modules are containers just like namespace in C#. They divide an angular app into small, reusable and functional components which can be integrated with other angular app. Each module is identified by a unique name and can be dependent on other modules. In AngularJS, every web page (view) can have a single module assigned to it via ng-app directive.
    
    Creating an AngularJS module 
    <script type="text/javascript">
    //defining module 
    angular.module('myApp', []); 
    //OR defining module which has dependency on other modules 
    angular.module('myApp', ['dependentModule1', 'dependentModule2']); 
    </script>
    Using an AngularJS module into your app You can bootstrap your app by using your AngularJS module as given below:
    <html ng-app="myApp"> 
    <head> ... </head>
    <body> ... </body>
    </html>

    1. Report
  3. Question:What components can be defined within AngularJS modules? 

    Answer
    You can define following components with in your angular module:
    1. Directive
    2. Filter
    3. Controller
    4. Factory
    5. Service
    6. Provider
    7. Value
    8. Config settings and Routes

    1. Report
  4. Question:What is core module in AngularJS? 

    Answer
    ng is the core module in angular. This module is loaded by default when an angular app is started. This module provides the essential components for your angular app like directives, services/factories, filters, global APIs and testing components.

    1. Report
  5. Question:How angular modules load the dependencies? 

    Answer
    An angular module use configuration and run blocks to inject dependencies (like providers, services and constants) which get applied to the angular app during the bootstrap process.

    1. Report
  6. Question:What is difference between config() and run() method in AngularJS? 

    Answer
    Configuration block – This block is executed during the provider registration and configuration phase. Only providers and constants can be injected into configuration blocks. This block is used to inject module wise configuration settings to prevent accidental instantiation of services before they have been fully configured. This block is created using config() method.
    angular.module('myModule', []).config(function (injectables) {
      // provider-injector 
      // This is an example of config block. 
      // You can have as many of these as you want. 
      // You can only inject Providers (not instances) 
      // into config blocks. 
    }).run(function (injectables) { 
      // instance-injector 
      // This is an example of a run block. 
      // You can have as many of these as you want.
     // You can only inject instances (not Providers)
     // into run blocks 
    });
    Run block – This block is executed after the configuration block. It is used to inject instances and constants. This block is created using run() method. This method is like as main method in C or C++. The run block is a great place to put event handlers that need to be executed at the root level for the application. For example, authentication handlers.

    1. Report
  7. Question:When dependent modules of a module are loaded? 

    Answer
    A module might have dependencies on other modules. The dependent modules are loaded by angular before the requiring module is loaded.
    
    In other words the configuration blocks of the dependent modules execute before the configuration blocks of the requiring module. The same is true for the run blocks. Each module can only be loaded once, even if multiple other modules require it.

    1. Report
  8. Question:What is Global API? 

    Answer
    Global API provides you global functions to perform common JavaScript tasks such as comparing objects, deep copying, iterating through objects, and converting JSON data etc. All global functions can be accessed by using the angular object. The list of global functions is given below:
    
    angular.lowercase - Converts the specified string to lowercase.
    angular.uppercase - Converts the specified string to uppercase.
    angular.forEach - Invokes the iterator function once for each item in obj collection, which can be either an object or an array.
    
    angular.isUndefined - Determines if a reference is undefined.
    angular.isDefined - Determines if a reference is defined.
    angular.isObject - Determines if a reference is an Object.
    
    angular.isString - Determines if a reference is a String.
    angular.isNumber - Determines if a reference is a Number.
    angular.isDate - Determines if a value is a date.
    angular.isArray - Determines if a reference is an Array.
    angular.isFunction - Determines if a reference is a Function.
    angular.isElement - Determines if a reference is a DOM element (or wrapped jQuery element).
    
    angular.copy - Creates a deep copy of source, which should be an object or an array.
    angular.equals - Determines if two objects or two values are equivalent. Supports value types, regular expressions, arrays and objects.
    
    angular.bind - Returns a function which calls function fn bound to self
    angular.toJson - Serializes input into a JSON-formatted string. Properties with leading $$ characters will be stripped since angular uses this notation internally.
    
    angular.fromJson - Deserializes a JSON string.
    angular.bootstrap - Use this function to manually start up angular application.
    angular.reloadWithDebugInfo - Use this function to reload the current application with debug information turned on.
    
    angular.injector - Creates an injector object that can be used for retrieving services as well as for dependency injection
    
    angular.element - Wraps a raw DOM element or HTML string as a jQuery element.
    angular.module - Used for creating, registering and retrieving Angular modules.

    1. Report
  9. Question:What is Angular Prefixes $ and $$? 

    Answer
    To prevent accidental name collisions with your code, Angular prefixes names of public objects with $ and names of private objects with $$. So, do not use the $ or $$ prefix in your code.

    1. Report
  10. Question:What are Filters in AngularJS? 

    Answer
    Filters are used to format data before displaying it to the user. They can be used in view templates, controllers, services and directives. There are some built-in filters provided by AngularJS like as Currency, Date, Number, OrderBy, Lowercase, Uppercase etc. You can also create your own filters.
    
    Filter Syntax 
    {{ expression | filter}}
    
    Filter Example 
    <script type="text/javascript"> 
    { { 14 | currency } } //returns $14.00 
    </script>

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd