Codepedia
.info
Home
jQuery
Angular
Asp.net
Asp.net Core
Sql
Demos
Tools
SVG Wave Generator
Twitter Trends
Colors
Coupons & Deals
Back to Article :
Angularjs call ajax function on page load
Edit This Code :
<html> <head><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <link rel='stylesheet' href='https://codepedia.info/wp-content/themes/themevicky/css/editor.css' type='text/css' /> </head> <body ng-app="myapp" ng-controller="myController" ng-init='init()' > <h2>GitHub JSON Data </h2><br/> <p>{{myData}}<p> <script type="text/javascript"> var app = angular.module("myapp", []); app.controller("myController", ['$scope','$http','$window' ,function ($scope,$http,$window) { $window.onload= function () { $http.get("https://api.github.com/users/isatindersingh/repos") .then(function(response) { $scope.myData = response.data; }); } }]); </script> </body> </html>
➤ Run / View
❱❱ View Article
Result :