AngularJs Call Function on Page Load with example
In this post we will show you how to create AngularJs Call Function on Page Load with different Examples. hear when your load page some type of event you can apply using this different method.
AngularJs Call Function on Page Load – There are some ways to decision a perform on page load in angularjs. you’ll use $window
object to decision a perform on page. Here during this tutorial we have a tendency to square measure progressing to justify however you’ll decision perform on page load in angularjs. we’ll justify this with example and demo.
Angular Call Function on Page Load
we can call a simply page load function using the $window.onload
as below with different Examples.
Angular Call Function on Page Load: Example 1
hear in give example we give for alert of page lode when you visit page or refresh page for AngularJs Call Function on Page Load with Example.
<!DOCTYPE html> <html lang="en"> <head> <title>AngularJs- Call Function on Page Load - onlinecode</title> <script SRC="href="http://www.onlinecode.org""></script> <script> var loadApp = angular.module("loadApp", []); loadApp.controller("loadController", function($scope, $window) { $window.onload = function() { alert("Alert Called on page load!!!"); }; }); </script> </head> <body> <div ng-app="loadApp"> <div ng-controller="loadController"> </div> </div> </body> </html>
Angular Call Function on Page Load: Example 2
hear in give example we give for print of page lode when you visit page or refresh page for AngularJs Call Function on Page Load with Example.
<!DOCTYPE html> <html lang="en"> <head> <title>AngularJs - Call Function on Page Load - onlinecode</title> <script SRC="href="http://www.onlinecode.org""></script> <script> angular.module('loadApp', []) .controller('loadController', [function() { angular.element(document).ready(function () { document.getElementById('msg').innerHTML = 'Hello on Called on page load'; }); }]); </script> </head> <body> <div ng-app="loadApp"> <div ng-controller="loadController"> <div id="msg"></div> </div> </div> </body> </html>
You also like Angularjs Moment Picker AND Angularjs Ng-Bind with Example