How to access the dynamic created function and models by Angular Js

Hello,

Today i am going to talk about How to Call Dynamic declared function by Angular js ?.

Like we use simple method to create the dynamic function in html.

//This is dynamic declared function call() which is used with HTML

var html_content = “<a href=’#’ ng-click=’call()’>”;

//Add this html in your page. In this step you need to make any Id to receive the html data from Angular Js. like

var $store_in_html_page  = $(html_content).appendTo(“#name of Id”);

// Now you need to use $compile. 

Now what is $compile ?

$compile is angular js service which is transverse the DOM looking for attribute.

How I use this ?

Its very simple

//Now you pass the "store_in_html_page" in compile function and call your scope . There $scope variable update the changes in controller so dynamic function easy to accessed by $scope.

$compile($store_in_html_page)($scope)

After this your dynamic created function easy to accessed by controller in every place of controller.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s