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 in Angular by kartik
• 1,910 points
25 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. 

answered Feb 4 by Niroj
• 3,230 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 in Angular by Niroj
• 3,230 points
22 views
0 votes
1 answer

What is isolated Scope in AngularJs?

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

answered Feb 5 in Angular by Niroj
• 3,230 points
14 views
0 votes
1 answer

What is transclusion in AngularJS?

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

answered Feb 5 in Angular by Niroj
• 3,230 points

edited Feb 5 by Niroj 20 views
0 votes
1 answer

What is transclusion Scope in AngularJs?

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

answered Feb 6 in Angular by Niroj
• 3,230 points
11 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 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 29 views
+1 vote
1 answer

What is css box module?

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

answered Jan 20 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 30 views
0 votes
1 answer

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

hii, visibility:hidden; and display:none are totally different used ...READ MORE

answered Jan 20 in Web Development by Niroj
• 3,230 points
57 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 in Web Development by Niroj
• 3,230 points

edited Jan 21 by Niroj 31 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 in Angular by anonymous
• 3,230 points
31 views
0 votes
1 answer

What is $parse in Angularjs

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

answered Feb 4 in Angular by Niroj
• 3,230 points
25 views