0

For some reason its giving me errors when i try to run this code. (i will post code then error at bottom):

index.html:

<!DOCTYPE html>
<html>

<head>
    <meta id="meta" name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <link href='https://fonts.googleapis.com/css?family=RobotoDraft:400,500,700,400italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="assets/dist/css/vendor.min.css" type="text/css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.9/angular-material.min.css" />
    <script type="text/javascript" src="assets/dist/js/vendor.min.js"></script>

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.9/angular-material.min.js"></script>


    <link rel="stylesheet" href="global.css" type="text/css" />


    <link href="https://code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="https://code.ionicframework.com/nightly/js/ionic.bundle.js"></script>



    <script type="text/javascript" src="app/app.module.js"></script>
    <script type="text/javascript" src="app/app.route.js"></script>
    <script type="text/javascript" src="assets/dist/js/app.min.js"></script>


</head>


    <body ng-app="Hive">


      <div ui-view class="main_view">
      </div>


   <ion-tabs class="tabs-icon-top tabs-energized">

        <ion-tab title="Home" icon="ion-home" ui-sref="home">
          <ion-nav-view name="home-tab"></ion-nav-view>
        </ion-tab>

        <ion-tab title="Discussions" icon="ion-android-contacts" ui-sref="discussions">
          <ion-nav-view name="discussions-tab"></ion-nav-view>
        </ion-tab>

        <ion-tab title="Board" icon="ion-ios-list-outline" ui-sref="board">
          <ion-nav-view name="list-tab"></ion-nav-view>
        </ion-tab>


             <ion-tab title="Me" icon="ion-android-happy" ui-sref="me">
          <ion-nav-view name="profile-tab"></ion-nav-view>
        </ion-tab>

      </ion-tabs>


  </body>


</html>

app.module.js:

(function (angular) {
    'use strict';
    angular.module('Hive', [
            'ionic',
            'firebase',
            'ngMaterial'
        ]
    );

});

app.route.js:

(function (angular) {
    'use strict';

    angular.module('Hive')
        .config(stateParams)

    /* @ngInject */
    function stateParams($stateProvider, $urlRouterProvider) {

        $stateProvider
            .state('home', {
                url: '/home',
                templateUrl:'app/components/home/home.html',
                controller: 'homeCtrl'
            })

            .state('me' , {
                url:'/me',
                templateUrl:'app/components/me/me.html',
                controller:'meCtrl'
            })

            .state('discussions' , {
                url:'/discussions',
                templateUrl:'app/components/discussions/discussions.html',
                controller:'discussionsCtrl'
            })

            .state('board', {
                url:'/board',
                templateUrl:'app/components/board/board.html',
                controller:'boardCtrl'
            })

            .state('register', {
                url:'/register',
                templateUrl:'app/components/register/register.html',
                controller:'registerCtrl'
            })


        $urlRouterProvider.otherwise('/home');

    }
})(angular);

I am getting the following errors when i run the code:

Error: $injector:nomod
Module Unavailable
Module 'Hive' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Error: $injector:modulerr
Module Error
Failed to instantiate module Hive due to:
Error: [$injector:nomod] http://errors.angularjs.org/1.2.7/$injector/nomod?p0=Hive
    at Error (native)
    at https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:3596
    at https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:10429
    at https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:10940
    at https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:14933
    at Array.forEach (native)
    at o (https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:3925)
    at r (https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:14873)
    at wt (https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:16490)
    at r (https://preview.c9users.io/amanuel2/hive/assets/dist/js/vendor.min.js:3:9097

I dont understand why i am getting these errors at all. I have been debugging for a long time now , but couldnt understand why. Right now im coding all this in website IDE : https://ide.c9.io/amanuel2/hive . Help would be appreciated ! :)

Edit (ngMaterial Not working ^^): index.html:

<head>
    <meta id="meta" name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <link href='https://fonts.googleapis.com/css?family=RobotoDraft:400,500,700,400italic' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="assets/dist/css/vendor.min.css" type="text/css" />
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.css">
    <script type="text/javascript" src="assets/dist/js/vendor.min.js"></script>



    <!-- Angular Material requires Angular.js Libraries -->
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-messages.min.js"></script>

  <!-- Angular Material Library -->
  <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc2/angular-material.min.js"></script>



    <link rel="stylesheet" href="global.css" type="text/css" />


    <link href="https://code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="https://code.ionicframework.com/nightly/js/ionic.bundle.js"></script>



    <script type="text/javascript" src="app/app.module.js"></script>
    <script type="text/javascript" src="app/app.route.js"></script>
    <script type="text/javascript" src="assets/dist/js/app.min.js"></script>


</head>


    <body ng-app="Hive">


      <div ui-view class="main_view">
      </div>


   <ion-tabs class="tabs-icon-top tabs-energized">

        <ion-tab title="Home" icon="ion-home" ui-sref="home">
          <ion-nav-view name="home-tab"></ion-nav-view>
        </ion-tab>

        <ion-tab title="Discussions" icon="ion-android-contacts" ui-sref="discussions">
          <ion-nav-view name="discussions-tab"></ion-nav-view>
        </ion-tab>

        <ion-tab title="Board" icon="ion-ios-list-outline" ui-sref="board">
          <ion-nav-view name="list-tab"></ion-nav-view>
        </ion-tab>


             <ion-tab title="Me" icon="ion-android-happy" ui-sref="me">
          <ion-nav-view name="profile-tab"></ion-nav-view>
        </ion-tab>

      </ion-tabs>


  </body>


</html>

app.module.js:

(function (angular) {
    'use strict';
    angular.module('Hive', [
            'ionic',
            'firebase',
            'ngMaterial'
        ]
    );

})(angular);
4
  • It looks like you are missing the second parameter to angular.module. try angular.module('Hive', []). If you don't pass that array in Angular will try to find an existing module called "Hive" instead of creating a new one Commented Jul 25, 2016 at 21:22
  • @rob if you see my code above i do indeed have a parameter with array: angular.module('Hive', [ 'ionic', 'firebase', 'ngMaterial' ] ); Commented Jul 25, 2016 at 21:23
  • Are you sure that app/*.js files are loaded? Commented Jul 25, 2016 at 21:25
  • ah sorry I miss that. Your app.module.js code is never being executed though. You wrapped it in a function that is never called Commented Jul 25, 2016 at 21:26

1 Answer 1

1

Shouldn't your app.module.js look like this:

(function (angular) {
    'use strict';
    angular.module('Hive', [
            'ionic',
            'firebase',
            'ngMaterial'
        ]
    );

})(angular);

You forgot to pass in the angular object.

Sign up to request clarification or add additional context in comments.

11 Comments

Yea thank a lot! That solved one error that was above but i still have one error left :( . Failed to instantiate module ngMaterial due to: Error: [$injector:modulerr] errors.angularjs.org/1.2.7/$injector/modulerr?p0=m...) at Error (native) at preview.c9users.io/amanuel2/hive/assets/dist/js/… at preview.c9users.io/amanuel2/hive/assets/dist/js/… at Array.forEach (native) at o.... Something wrong with ngMaterial but i cant possibly find whats wrong :(
You don't seem to have a script or stylesheet referencing ngMaterial in your <head> ... </head> tag.
ngMaterial requires multiple Angular libraries than just the base. Check this example: material.angularjs.org/1.0.5/getting-started
Yup exactly^^^. You need to add all the dependencies.
@austinthedeveloper and 1290 , i copied the exact refrences in material , but still having the same problem. Look at my edit above in question to see the current index.html and app.module.js :(
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.