Hello again, everyone.
So in our last lesson, we introduce the subject of data binding.
Now, I'll continue on this topic in this lesson, because I want to show you the use of string interpolation.
So I want to continue on this component.
Now, see here, there's a static variable in the HTML page.
Actually, we want to make it static.
So I want this to change with variables, I will use the typescript page.
Now, let's see how we do it.
So look at this here now we are showing a product here, and I want this product to have an I.D. and
I want to make this I.D. definition and typescript file.
Actually, I use it in the e-mail page.
So now I'll create this dynamic feel and the typescript file.
And we're going to do these operations in this class.
I'm now defining a number variable as product ID, and I'll write one as the value.
That the second variable we can check whether to see if it's in stock or not.
So define a string variable and call it stock status.
So we can enter yes or no as a value right now and ah, yes.
Now, as we talked about earlier in typescript, we had no problem when we give an initial value here.
So I've used this variable as no, but of course, we can use it that way, right?
Same goes for string values.
Right, so I choose to use it here so that you can see both uses.
All right.
So now it's time to learn how to use these variables in the HTML file.
So now I'm doing the edits here and.
The first to come up will be the first dynamic variable in these.
Now we've got to use double curly braces to define this variable here.
And inside of that, I write a variable name.
There may be different uses between these brackets, of course.
For example, we can write a string value or we can call a string method or.
We can do mathematical operations, for example, adding to numbers, but we won't be able to use multiple
lines, block statements or loops, does that make sense?
So as a result, the value is going to be a string.
All right, so that is the basic use of string interpolation.
We've defined a variable in the typescript file and we called it in double curly braces inside the HDMI
file.
All right, so now let's finish the edits and see what we can do in the browser.
And here we can see the values that we give to typescript and look at this, we actually define the
ID value as number.
We said in the string interpolation, the result would be string.
And this didn't cause any problems because and no value can easily be converted to a string.
So that's no problem.
But now I want to show you how to use the method and double brackets before we finish our lesson.
So for this, I'll first write a simple method in the typescript file and return this value with method.
Now, I call Method in HTML and.
There's no change when we've saved the changes because the result of the method turned into a string
easily and it worked without any problems.
All right.
So that's how I use string interpolation.
Now we're going to talk about property buiding and our next lesson.
So until then.
Have some fun, but review a few things as well.
All right, see you next time.