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!!