What is so different about interpolate in AngularJS

0 votes
Want to know what's the difference in using interpolate and parse and what is the use of it?
Feb 4, 2020 in Angular by kartik
• 37,520 points
1,630 views

1 answer to this question.

0 votes

hii @kartik,

In order to know about what interpolate does you should first know what $parse does in AngularJs as i have explain it earlier and then you refer this to identify what the difference between them.

Interpolation markup with embedded expression will provide data binding to text nodes and attribute values.

Let me explain you with an example/s:

Consider the following code:

var app=angular.module('app',[])
app.controller('sample',['$scope',function($scope){
$scope.a=10;
$scope.b=20;
$scope.demoInterpolate=function(){
var f=$Interpolate(result={{a*b}});

var r=f($scope);

alert(r);
}]);

From above it can be seen that the expression var f=$Interpolate(result={{a*b}});  has taken an input {{a*b}} which is javascript expression and the after evaluate the result will be passed to interpolate and just like $parse, $interpolate also return a function and that function can be used against any object but this cann't be done using $parse

The above code can have short end form as well:

alert($interpolate(result={{a*b}})($scope));

Key points: Just like $parse we use interpolate here except that the interpolate actually work with string and all the angular expression mixed up.  The main thing about interpolate is that we can also use filter in it but not in case of $eval and $parse. 

Hope it helps!!

To know more about Angular, Join Angular training online today.

Thank you!!

answered Feb 4, 2020 by Niroj
• 82,840 points

Related Questions In Angular

0 votes
1 answer

What is Scope Parameter in AngularJS?

Hey @kartik, Scope Parameter is a collection of ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,840 points
1,074 views
0 votes
1 answer

What is isolated Scope in AngularJs?

Hello kartik, As we know Scope is a ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,840 points
799 views
0 votes
1 answer

What is transclusion in AngularJS?

Hey, Let me explain you about transclusion from ...READ MORE

answered Feb 5, 2020 in Angular by Niroj
• 82,840 points

edited Feb 5, 2020 by Niroj 877 views
0 votes
1 answer

What is transclusion Scope in AngularJs?

hey @kartik, Let me start with What is ...READ MORE

answered Feb 6, 2020 in Angular by Niroj
• 82,840 points
877 views
+1 vote
1 answer

What is the relationship between angularjs Scope with controller/view?

Let us consider the below block: <div ng-controller="emp"> ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,190 views
+1 vote
1 answer

What is css box module?

Hey, All the element present in html follows ...READ MORE

answered Jan 20, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 1,224 views
0 votes
3 answers

Explain the difference between visibility:hidden; and display:none?

display:none means that the tag in question will ...READ MORE

answered Dec 14, 2020 in Web Development by Gitika
• 65,770 points
119,788 views
+1 vote
1 answer

How to access the Angularjs scope of a particular html element from our console?

Hello, You should follow the below steps:-- 1.Compile and ...READ MORE

answered Jan 21, 2020 in Web Development by Niroj
• 82,840 points

edited Jan 21, 2020 by Niroj 3,032 views
0 votes
1 answer

What is $watch() and it's use in AngularJS?

$watch() function is used to watch the ...READ MORE

answered Feb 3, 2020 in Angular by anonymous
• 82,840 points
2,516 views
0 votes
1 answer

What is $parse in Angularjs

Before we jump into the topic you ...READ MORE

answered Feb 4, 2020 in Angular by Niroj
• 82,840 points
2,551 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP