- AngularJS provide $interpolateProvider for configuring the start and end symbol of expression.
- AngularJS expression takes double curly braces {{expression}} by default.
- Using startSymbol() and endSymbol() method we can change these default value to a different tag.
- In this demo,"We will use $interpolateProvider to change the start and end tag of AngularJS expression".
- Below code has the use of startSymbol() and endSymbol() method to change the AngularJS expression start and end tag to double square bracket.
<!DOCTYPE html> <html ng-app="myApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>AngularJS $interpolateProvider Example</title>
</head>
<body ng-controller="MyController">
<h3>$interpolateProvider startSymbol() and endSymbol</h3>
<h4>[[myName]]</h4>
<script>
var myApp = angular.module("myApp", []);
myApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
myApp.controller("MyController", ["$scope", function($scope) {
$scope.myName = "Sandeep Kumar Patel";
}]);
</script>
</body>
</html>
- The output of the above code has been embedded in below JSBIN link.