title: How can i pass the values i receive from SignalR to my array in Angular?
body: <p>i'm using SignalR with net framework and want to implement with Angular 8. I tryed to use the simple chat example on .net framework mvc but i'm having problems with broadcastMessage.</p>
  
  <p>In C#</p>
  
  <pre><code>public class Chathub : Hub
      {
          [EnableCors(origins: "*", headers: "*", methods: "*")]
          public void Send(string name, string message)
          {
              // Call the broadcastMessage method to update clients.
              Clients.All.broadcastMessage(name, message);
          }
      }
  </code></pre>
  
  <p>In Angular component i created an array so i could push messages to this array and show in realtime on my page, this is how i made</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div&gt;
      &lt;div  *ngFor="let item of mensagens"&gt;
        {{item.nome}}: {{item.mensagem}}
      &lt;/div&gt;
  </code></pre>
  
  <p>Component</p>
  
  <pre><code>@Component({
    selector: 'app-home',
    templateUrl: 'home.page.html',
    styleUrls: ['home.page.scss'],
  })
  export class HomePage {
  
    chat:any;
    mensagens: {
      nome: string, mensagem: string
    }[];
  
    constructor() {
      this.chat = $.connection.chathub;
      this.chat.connection.url = 'http://localhost:61708/signalr';
      this.chat.client.broadcastMessage = function(name: string, message: string)
      {
        this.mensagens.push({nome: name, mensagem: message});
      };
      $.connection.hub.start().done(function () {
        console.log('conected');
      });
    }
  </code></pre>
  
  <p>The problem is that in the broadcastMessage function, when i try to access "this.mensagens" ins undefined. I can't access mensagens from that function. How can i pass the values i receive from the broadcastMessage to my array? Thank you.</p>