Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make ajax hit in Angular JS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 233
    Comment on it

    Hello Reader's if you want to get data from another webpage then you have to make ajax hit. Angular JS also provide you to get your data and redesign it into it's script. Then you can generate the design itself. Let's see it's working example as below:-

    <!DOCTYPE html>
    <html >
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <body>
    
    <div ng-app="myApp" ng-controller="customersCtrl"> 
    <table>
      <tr ng-repeat="x in names">
        <td>{{ x.Name }}</td>
        <td>{{ x.Country }}</td>
      </tr>
    </table>
    
    </div> 
    <script>
    var app = angular.module('myApp', []);
    app.controller('customersCtrl', function($scope, $http) {
       $http.get("http://www.w3schools.com/angular/customers&#95;mysql.php")
       .then(function (response) {$scope.names = response.data.records;});
    });
    </script>
    </body>
    </html>
    

    Here in the code above data is passing through customers_mysql.php page and we have desing it into table.Now the final data on the current page will be nice formated and will be shown in tables.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: