我有一個常數值,在我的項目中是常見的,在我的兩個模塊中 - 我想要一個設計,我只需要在一個模塊中定義它並傳遞值到另一個模塊。我怎麼能 - ? 模塊1就像是在控制器之間傳遞一個常量值angularjs
var myApp = angular.module('myApp', ['ui.router']);
myApp.constant('constVar', 'http://45.26365.23/mydata/');
1和Module2就像
var Dashboardapp =angular.module('Dashboardapp', ['ui.router']);
Dashboardapp.constant('constVar', 'http://45.26365.23/mydata/');
你可以把這個常量放在'$ rootScope'中並且在你的應用程序的任何控制器中訪問它 –
@AgamBanga我不確定'$ rootScope'可以在**應用程序之間共享常量**。 – cezar