W
W
WarGot2016-10-29 13:00:00
Angular
WarGot, 2016-10-29 13:00:00

How to call the controller from the console?

There is an application in angular. Assembled, works. There was a problem with the mozilla sdk event handling in order to package the application into a fox plugin.
An Angular application is built like this

// Mount on window for testing
window.app = angular.module('app', requires);

angular.module('app').constant('AppConstants', constants);

angular.module('app').config(appConfig);

angular.module('app').run(appRun);

angular.bootstrap(document, ['app'], {
  strictDi: true
});

The second .js file has an event call and its listener, conditionally like this:
loginPanel.port.emit("load_page", someValue); // вызов события

listener:
self.port.on("load_page", function onShow(someValue) {
    console.error(someValue);
    // вот тут надо передать вызвать метод из класса  контроллера и передать данные
});

The controller looks something like this:
class HomeCtrl {
  constructor(User, Tags, AppConstants, $scope, Api, Storage) {
    'ngInject';

console.log('contruct');
  }
  test(){
    console.error('test method from home controller');
  }
}
export default HomeCtrl;

By chain
window.app.controller('homeCtrl', ['$scope', function ($scope) {

}]);

it seems like I get a controller object, but I can’t find an example of how to call a method and pass data there.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question