What function $parse() does in AngularJS? Documentation of AngularJS has very shot and vague explanation. For instance,
context – {object} – an object against which any expressions embedded in the strings are evaluated against
Very unclear for me. I comprehend that $parse() returns a function. But what this function carries? What for? And how to use result of this function?
AngularJs $parse
return a function and can be execute immediate after with $scope
. This can be used for single variable getter
and setter
. eg
$scope.name = 'John Doh';
$parse('name')($scope); //this will result in John Doh
$parse('name').assign($scope,'Foo Bar');
Angular expressions also can be used as a string argument.