angularjs - Is it possible to inject into the main controller and have it be available to other controllers? Ionic -
for example, app.controller main controller.
app.controller('appcontroller', ['$scope','$ionicnavbardelegate', function ($scope,$ionicnavbardelegate) { }]);
and second controller :
app.controller('loginpage', ['$scope','$ionicnavbardelegate', function ($scope,$ionicnavbardelegate) { }]);
can pass $scope in main controller , have passed along loginpage controller without typing out again in loginpage controller?
yes can pass data 1 controller other using
$rootscope
for
app.controller('loginpage', ['$rootscope','$scope','$ionicnavbardelegate', function ($rootscope,$scope,$ionicnavbardelegate) { $rootscope.items = "rootscope varibale"; }]); app.controller('appcontroller', ['$rootscope','$scope','$ionicnavbardelegate', function ($rootscope,$scope,$ionicnavbardelegate) { console.log($rootscope.items); }]);
Comments
Post a Comment