Angular Call Function on Page Load Example

Today, We want to share with you Angular Call Function on Page Load Example.
In this post we will show you AngularJs Call Function on Page Load Example, hear for AngularJS – How to execute AngularJS function on page load we will give you demo and example for implement.
In this post, we will learn about AngularJS – How to call function on page load example with demo with an example.

The simple function Window.onload function we can impo. use to perform some call function or task as well as the some page finishes loading in javascript.

READ :  AngularJS Controllers Inheritance - angular inherits Example

Welcome to the In infinityknow.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.AngularJs Call Function on Page Load Example

Example 1 : angularjs fire function on page load



<title>
Simple Example of angularjs run function on load (onload)
</title>
 
 
var ngApp = angular.module("infinityknowApp", []);
 ngApp.controller("ngAppCtrl", function($scope, $window) {
$window.onload = function() { // onload function call
 alert("Simple Called on page load in angularjs..");
 console.log(In function call);
};
});
 

  
<div>  
	<div>  
		<h1>Simple AngularJs Call Function on Page Load Example</h1>
		<p>In infinityknow.com blog is very useful in AngularJs with demo and Example</p>
		There are Follwing List Of My Google Blogspot Tutorials
		
		<a href="https://infinityknow.com/">infinityknow</a>
		<a href="https://w3free.com">W3FREE</a>
		<a href="https://pakainfo.com">pakainfo</a>
		<a href="https://pakainfo.com">pakainfo</a>
		<h3 class="well">
			The infinityknow.com is a special post of AngularJs Example , source code and demo easy to used.It's blogs very best usefull example getting in this site.
		</h3>
		
		Please Open This URL and enjoyed It!! :) Angular.king
	</div>  
</div> 
 
  
    

Example 2 : execute function on page load in angular

angular.element(document).ready(function () {
	console.log(In function call);
    alert("Simple Called on page load in angularjs.."); // your angular code here
	
});

Example 3 : Angularjs on page load call function

angular.module('infinityknowApp', [])
  .controller('salesorderCtrl', ['$scope', function($scope) {
    salesCreateFunction(); // call function
	console.log(In function call);
  }]);
  
function salesCreateFunction()
{
	alert("Simple demo angularjs fire function on page load");
	console.log(In function call);
}
  

Example 4 : angularjs execute function on page load Example

var $scope.init = function(){
	    alert("Simple Called on page load in angularjs Example with demo.."); // your angular code here
			$http.post('http://url',data)
				.success(function(msg) {
					 var uid=msg.SessionId;
					var uname=msg.UserName;
					if(uid){
							var $promise=$http.post('ng/data/user.php',msg); 
							console.log(In function call);
							//scope.msgtxt='Correct information';
							sessionService.set('uid',uid);
							$location.path('/homepage');
						}	       
						else  {
							
							scope.msgtxt='incorrect information';
							$location.path('/loginpage');
							console.log(out function call);
						}
		
}

$timeout($scope.init)

demo

http://jsfiddle.net/jgentes/stwyvq38/1/

READ :  The Future of AngularJS Framework