Reputation: 1553
From a child component, using angular output, I am emitting a string value. What I want that, in the parent component, I will receive that string and will concatenate with the existing value.
parent component has a variable called customValue: string;
Now these peice of code is working customValue = customValue+ $event +' '
<parent>
<child (stringValue)="customValue = customValue+ $event +' '"> </child>
</parent>
But if i try to concanate like this: customValue += $event +' '
then its not working.
<parent>
<child (stringValue)="customValue += $event +' "> </child>
</parent>
Can someone please tell me why the above string concatenate is not working?
please note: I really do not want to create a function. Is there any way that without creating a function I can achieve what I desire for?
Upvotes: 2
Views: 162
Reputation: 1944
From the angular docs:
The following JavaScript and template expression syntax is not allowed:
new
increment and decrement operators, ++ and -- operator
assignment, such as += and -=
the bitwise operators, such as | and & operator
Templates do not support some of the JavaScript features
Upvotes: 3