1

I am experienced, but new to Aurelia and cannot figure out how to call a specific function from the console.

Using this source:

<code>
import {} from 'css/style.css';
import {inject} from 'aurelia-framework';
import {DOM} from 'aurelia-pal';    
export class App {
  constructor() {
    this.message = 'Test Application';
    this.todos = ['a','b','c','d'];
    this.DOM = DOM;
  }
    getFish() {
        this.DOM.getElementById("#theMessage").style.color="green";
    }
}
</code>

I want to call getFish from the console. One may think that App.getFish() would do it, but no so much.

How DOES one call class functions in the debug console for Aurelia?

Norm Strassner
  • 225
  • 3
  • 11

1 Answers1

2

I would simply log this in the constructor or really in any of the VM's functions:

 export class App {
   constructor() {
     console.log('App VM', this); 
   }

   getFish() {
     console.log('get fish called');
   }
 }

Then I would right click on the the object that is logged and click "Store as global variable." That will give me a variable to use. I can then call the function as desired.

right click on the logged object and choose Store as global variable

calling function on VM

Ashley Grant
  • 10,879
  • 24
  • 36