Cannot load any $ionicModal or $ionicLoading

Every time i try to use either $ionicLoading or $ionicModal in my controller i get the following error:

  Error: $ionicLoading is undefined
$scope.show@http://localhost:8383/Musica/js/controllers.js:43:21
$scope.search@http://localhost:8383/Musica/js/controllers.js:13:25
Parser.prototype.functionCall/<@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:18471:1
ngEventHandler/</callback@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:26758:28
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:20326:9
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:20424:11
ngEventHandler/<@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:26763:17
createEventHandler/eventHandler/<@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:10478:7
forEach@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:7950:9
createEventHandler/eventHandler@http://localhost:8383/Musica/lib/ionic/js/ionic.bundle.js:10477:5

This is my controller code:

angular.module('starter.controllers', [])

        .controller('searchController', ['$scope', function ($scope, $ionicLoading) {
   $scope.show = function () {
                    $ionicLoading.show({
                        template: 'Loading...'
                    });
                };
                $scope.hide = function () {
                    $ionicLoading.hide();
                };
            }]);

I guess the problem is about the scope but not sure how i can fix so that i can use loading or modal.

if you define your app and bootstrapping it on your own -> your have to write the dependencies in the array
like angular.module(‘myApp’, [‘ionic’, ‘maySomeOther’])

angular.module('starter.controllers', ['ionic'])

    .controller('searchController', ['$scope', '$ionicLoading', function ($scope, $ionicLoading) {
           $scope.show = function () {
                $ionicLoading.show({
                    template: 'Loading...'
                });
            };
            $scope.hide = function () {
                $ionicLoading.hide();
            };
        }]);
1 Like

Thanks mate that solved it !