How to make Rest API Basic Authentication with AngularJS?


#1

I am new to ionic framework, i have tried to get the value using Restful API with Basic Authentication. My code is,

        var exampleApp= angular.module('starter', ['ionic']);                                                                                                  exampleApp.controller('ExampleController', function($scope, $http) {
         $scope.getData = function() {
$http.get("http://localhost/smart/api/request/section", { params: { "key1": "value1", "key2": "value2"               } })
        .success(function(data) {
        alert("SUCCESS");
        console.log(data[0]['floor_no']);
        $scope.firstname = data[0]['section'];
        $scope.lastname = data[0]['floor_no'];
    })
    .error(function(data) {
        alert("ERROR");
    });
 }

Above code work fine without authentication rest api, but i need rest api basic authentication.