develephant / ngElectron

The ngElectron service for AngularJS making it easier to interface with Electron.
Other
59 stars 15 forks source link

Pass $scope with 2 controllers on 2 different electron windows with $rootScope.$broadcast #12

Open lucav90 opened 7 years ago

lucav90 commented 7 years ago

hi,

how can i pass $scope and another variabile with angular on many electron windows?

This is my project:

i have my angular app with your ng-electron. It is very good!

in my index.html i have 2 controllers: home and data.

my data controller html into index.html is:

<div class="datas" ng-controller="data">
    data: {{data}}
</div>

in home controller i have a function to create another electron window with (electron.browserWindow etc) where i load another html file (index2.html).

so, i have 2 electron windows with different html file but same angular controller.

In this index2.html i have the same data controller. This:

<div class="datas" ng-controller="data">
    data: {{data}}
</div>

in data controller, i have inserted the $rootScope.$watch and other to read the new value of $rootscope.data that i change in my first window.

$scope.$on('read_scope', function(response,value) {
    alert('value);
})
$rootScope.$watch('scope', function(newValue, oldValue){ })

But the $rootscope.data value changed is read and works only on the first windows, if i have 2 electron windows open doens't work. The 2° windows load the default $rootscope.data

i want that the 2 electron windows display the changed data in the same moment.

How can do this? How can pass scope on all electron windows?

regards,

lucav90 commented 7 years ago

no solution?