1. Question:Which components can be injected as a dependency in AngularJS? 

    Answer
    AngularJS provides a supreme Dependency Injection mechanism. It provides following core components which can be injected into each other as dependencies.
    
    value
    factory
    service
    provider
    constant

    1. Report
  2. Question:How to make an ajax call using Angular JS? 

    Answer
    AngularJS provides $http control which works as a service to make ajax call to read data from the server. The server makes a database call to get the desired records. AngularJS needs data in JSON format. Once the data is ready, $http can be used to get the data from server in the following manner:
    function studentController($scope,$http) {
       var url = "data.txt";
       $http.get(url).success( function(response) {
          $scope.students = response; 
       });
    }

    1. Report
  3. Question:What is use of $routeProvider in AngularJS? 

    Answer
    $routeProvider is the key service which set the configuration of urls, maps them with the corresponding html page or ng-template, and attaches a controller with the same.

    1. Report
  4. Question:How to validate data in AngularJS? 

    Answer
    AngularJS enriches form filling and validation. We can use $dirty and $invalid flags to do the validations in seamless way. Use novalidate with a form declaration to disable any browser specific validation.
    
    Following can be used to track error.
    
    $dirty − states that value has been changed.
    
    $invalid − states that value entered is invalid.
    
    $error − states the exact error.

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