由于某些原因,当我尝试运行此代码时,它会给我错误。 (我将在底部发布代码然后错误):
的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);
运行代码时出现以下错误:
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
我不明白为什么我会得到这些错误。我已经调试了很长时间了,但不明白为什么。现在我在网站IDE中对所有这些进行编码:https://ide.c9.io/amanuel2/hive。帮助将不胜感激! :)
编辑(ngMaterial不工作^^): 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);
答案 0 :(得分:1)
不应该app.module.js
看起来像这样:
(function (angular) {
'use strict';
angular.module('Hive', [
'ionic',
'firebase',
'ngMaterial'
]
);
})(angular);
你忘了传递棱角分明的物体。