Search code examples
angularjsangularjs-scopeangularjs-ng-repeat

Angular: Access variables from outside scope of ng-repeat


I am having issues accessing variables (attached to $scope) inside ng-repeat loop. My ng-repeat is as follows:

<div class="row" ng-repeat="Message in Messages">
    <p>{{ Message.Sender ChattingWith}}</p>
</div>

I can use ChattingWith variable outside the ng-repeat but can't use it inside for some reason. I have used $parent.ChattingWith without any luck. Any help would be appreciated.


Solution

  • Write code like this:

    <div class="row" ng-repeat="Message in Messages">
        <p>{{ Message.Sender + ChattingWith}}</p>
    </div>
    

    This will solve the problem.