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.

READ :  php sort multidimensional array by value descending 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.

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

[php]

<br /> Simple Example of angularjs run function on load (onload)<br />

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);
};
});

READ :  Advantages and Features of DOMO

Simple AngularJs Call Function on Page Load Example

In infinityknow.com blog is very useful in AngularJs with demo and Example

There are Follwing List Of My Google Blogspot Tutorials

infinityknow
W3FREE
pakainfo
pakainfo

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.

Please Open This URL and enjoyed It!! 🙂 Angular.king

[/php]

Example 2 : execute function on page load in angular

[php]

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

});

[/php]

Example 3 : Angularjs on page load call function

[php]

READ :  Load More Data on Page Scroll using Ajax Jquery Laravel 6

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);
}

[/php]

Example 4 : angularjs execute function on page load Example

[php]

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)

[/php]

demo

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

Leave a Comment