J’ai réussi à solutionner le problème, en me basant sur le code javascript de la console constellation.
L’idée est de créer le ‘constellationConsumer’ dans le script principal, au niveau de l’appel de la fonction .run dédiée à l’angular, et de faire en sorte que notre consumer soit une variable globale pour tout le projet, en utilisant un $rootScope.
En pratique, on obtient la structure suivante :
Dans l’app.js, avec les fonctions pour récupérer tous les states objects disponible
angular.module('remote', ['ionic', 'ngConstellation', 'remote.controllers', 'remote.constellationScripts'])
.run(['$ionicPlatform', '$rootScope', 'constellationConsumer', function ($ionicPlatform, $rootScope, consumer) {
$ionicPlatform.ready(function () {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (cordova.platformId === 'ios' && window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
$rootScope.consumer = consumer;
$rootScope.connectionState = 'Disconnected';
$rootScope.consumer.intializeClient("serrverURL", "serverAccesKey", "consumerFriendlyName");
$rootScope.consumer.onUpdateStateObject(function (stateobject) {
$rootScope.$apply(function () {
if ($rootScope.consumer[stateobject.PackageName] == undefined) {
$rootScope.consumer[stateobject.PackageName] = {};
}
$rootScope.consumer[stateobject.PackageName][stateobject.Name] = stateobject;
})
});
$rootScope.consumer.onConnectionStateChanged(function (change) {
$rootScope.connectionState = change.newState === $.signalR.connectionState.connected ? "Connected" : "Disconnected";
if (change.newState === $.signalR.connectionState.connected) {
$rootScope.consumer.requestSubscribeStateObjects("*", "*", "*", "*");
}
$rootScope.$apply();
});
$rootScope.consumer.connect();
}])
.config(function ($stateProvider, $urlRouterProvider) {
//configuration des controllers associés à chaque page
});
Dans remote.controllers.js, j’ai les différents controllers utilisés.
Pour pouvoir exploiter constellation, il faut simplement passer par le $scope (ici, je l’ai appelé consumer, donc $scope.consumer fera référence à ma constellation)
J’espère que ça sera assez clair si quelqu’un cherche la solution au même problème.