I’m facing this issue. Dunno what’s going wrong here.
angular.module(‘samApp’, [‘ionic’])
.config(function($stateProvider, $urlRouterProvider) {
})
.run(function ($ionicPlatform, $ionicPopup) {
//$ionicPopup is injected properly here…
})
.controller(‘appCntrl’, function($scope, $state, $ionicPopup) {
//$ionicPopup is not defined here…
});
Please help…
fact: you dont need to inject ionic popup in the run function, only in the controller.
but anyway ionicPopup should be available in the controller. can you create a codepen?
What error do you get? Could you log $ionicPopup
? Are you sure the controller name is appCntrl
? is appCntrl defined somewhere in you app?
Hey! I just figured this…
This wont work:
angular.module(‘samApp’, [‘ionic’])
.config(function($stateProvider, $urlRouterProvider) {
})
.run(function ($ionicPlatform, $ionicPopup) {
//$ionicPopup is injected properly here…
})
.controller(‘appCntrl’, [’$scope’, function($scope, $ionicPopup) {
//$ionicPopup is not defined here…
}]);
This works:
angular.module(‘samApp’, [‘ionic’])
.config(function($stateProvider, $urlRouterProvider) {
})
.run(function ($ionicPlatform, $ionicPopup) {
//$ionicPopup is injected properly here…
})
.controller(‘appCntrl’, function($scope, $ionicPopup) {
//$ionicPopup is now defined properly here…
});
Glad you solved it but as a suggestion, always use the array notation because if you want to minify it, you will get errors:
.controller('appCntrl', ['$scope', '$ionicPopup', function($scope, $ionicPopup) {
...
}]);