So, I have this ng-repeat where I call a class to set the text if the text attribute has content. This text attribute which in turn will be get binded in the html side. However, only the last variable that got set will be reflected even with the previous data in the repeater.
Here is my code
<div ng-repeat="x in data">
<p ng-init="setText(x.text);">{{ ::titleText}}</p>
</div>
$scope.setText = function(text) {
$scope.titleText = text;
if (!$scope.titleText) {
$scope.titleText = 'Blabla';
}
};
For example if i have
x[0].text = '';
x[1].text = '';
x[2].text = '';
x[3].text = 'Test';
My expectations would be that x[0-2].text would equals to 'Blabla' but it ends up being 'Test'
I am not sure how to solve this issue.