How to use javascript function in string interpolation in AngularJS ? Last Updated : 03 Jun, 2021 Suggest changes Share Like Article Like Report String interpolation is basically used to display the dynamic data on an HTML template. It facilitates you to make changes on component.ts file and automatically fetch data from there to the HTML template (component.html file). So here we create a simple HTML template that uses the string interpolation, and then we write the function that is used inside the string interpolation. Approach : Create the Angular app to be used.Create a component "DemoComponent". In the demo.component.ts create some methods that we used inside the string interpolation.Here we are also using the inbuilt JavaScript function inside the string interpolation. Syntax : <h4>Book Price : {{ 'SHOULD BE LOWER CASE'.toLowerCase() }}</h4> Example 1: (In-Build Functions) Add the below HTML inside angular template and run using "ng serve" and it makes the string lower-case. example.component.html <h4>Book Price : {{ 'SHOULD BE LOWER CASE'.toLowerCase() }}</h4> <hr/> Output : Example 2: (Custom Functions) demo.component.ts import { Component } from '@angular/core'; @Component({ templateUrl: './demo.component.html', styleUrls: ['./demo.component.css'] }) export class DemoComponent{ public Books = [ {name:"The Pilgrim’s Progress",author:'John Bunyan',price:"13"}, {name:"Robinson Crusoe",author:'Daniel Defoe',price:"43"}, {name:"Gulliver’s Travels",author:'Jonathan Swift',price:"33"} ] constructor(){} printBookName(book){ return "[ " + book.name + " ]"; } printBookAuthor(book){ return "[ " + book.author + " ]"; } printBookPrice(book){ return "[ " + " $" + book.price + " ]"; } } In the above code, we have created a books array which store the book object and then we have created three functions and we are going to use these three function inside string interpolation to print specific book detail. demo.component.html <div style="margin-left:100px" *ngFor="let book of Books"> <hr> <h4>Book Name : {{ printBookName(book) }}</h4> <h4>Book Author : {{ printBookAuthor(book) }}</h4> <h4>Book Price : {{ printBookPrice(book) }}</h4> </div> Output: Here in the HTML template, we are using a function inside string interpolation to print specific book data. Advertise with us Next Article How to use javascript function in string interpolation in AngularJS ? D daya1331 Follow Similar Reads How to transform String into a function in JavaScript ? In this article, we will see how to transform a String into a function in JavaScript. There are two ways to transform a String into a function in JavaScript. The first and easy one is eval() but it is not a secure method as it can run inside your application without permission hence more prone to th 3 min read String Interpolation in JavaScript These are the following ways to interpolate the given strings:1. Template Literals (ES6)Template literals are the most modern and preferred method for string interpolation in JavaScript. They use backticks (`` ` ``) and ${} syntax to embed expressions.JavaScriptconst n = "Alice"; const res = `Hello, 2 min read Interpolation vs. Property Binding in Angular Angular, a powerful front-end framework, offers various techniques to dynamically update and display data in your applications. Two commonly used methods for this purpose are interpolation and property binding. In this article, we will learn about interpolation and property binding and also see the 4 min read How to replace a string by another string in AngularJS ? In this article, we will see how to select a string from the text and replace it with another string using AngularJS and will understand it through the illustrations. The replace() method can be used to search the particular character(s), which is getting replaced with a specific character(s) & 2 min read How To Display Values With Interpolation In Angular? Angular is a powerful framework for building dynamic web applications. One of its key features is data binding, which allows developers to display and update values seamlessly within the UI. Interpolation is a fundamental technique in Angular that enables the integration of component data directly i 3 min read Article Tags : Web Technologies AngularJS AngularJS-Function AngularJS-Questions Like