AngularJS – How to Pass Parameters to Controllers on Initialization

In this Post We Will Explain About is AngularJS – How to Pass Parameters to Controllers on Initialization With Example and Demo.

Welcome on – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS : passing params from controller to service

In this post we will show you Best way to implement Parameters for initialize controllers, hear for How to Passing Value to a Angular Controller from MVC Controller with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  Angular use scope object Example

Define an Angularjs init function in ng controller such as following source code:

we came across a usecase where we had to edit an existing object.
So, we was required to simple populate the input data fields with existing value.
When we some tried to do in usual steps to manner which is like simple retrieving simple the object from server and data updating each of the HTML input fields with the right value,here it didn’t work out.
The input fields were not getting the value retrieved from server.
This is simple primarily simple data because the model values were all the initialized with setting default values when using anhularjs ng-app bootstrapped and some as a load mode to controller intialization angularjs ng-init assigned the default values to simple model that were data bound to input field.

READ :  Vuejs Upload using http post and FormData - vue file upload component

liveApp.controller( "liveCtrl", ['$scope', function( $scope ) {

	this.initialize = function( fname, lname, age ) {
	    this.livedata = fname;
	    this.address = lname;
	    this.age = age;


Attach ng-init directive

Attach ng-init directive to the element which consists of ng-controller in the following manner. In the example below, fnameStr, lnameStr and ageStr represents the variable that consists of actual value retrieved from the server.



I hope you have Got AngularJS : passing params from controller to service And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.