Angular Call Function on Page Load Example

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 :  PHP Retype New Password Confirmation 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

<html lang="en">
<head>
<title>
Simple Example of angularjs run function on load (onload)
</title>
 <script src="yourappfolder/1.2.13/angular.min.js"></script>
 <script>
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);
};
});
</script> 
</head>
<body>  
<div ng-app="infinityknowApp">  
	<div ng-controller="ngAppCtrl">  
		<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/" alt="Happy 2 help you in angularjs">infinityknow</a>
		<a href="https://w3free.com" alt="Happy 2 help you in w3free">W3FREE</a>
		<a href="https://pakainfo.com" alt="Happy 2 help you in pakainfo">pakainfo</a>
		<a href="https://pakainfo.com" alt="pakainfo">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> 
 
</body>  
</html>    

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 :  Angular use scope object Example

Add a Comment

Your email address will not be published. Required fields are marked *