HI出现此错误
ionic.bundle.js:13443未捕获错误:[$ injector:modulerr]由于以下原因导致无法实例化模块启动器: 错误:[$ injector:modulerr]由于以下原因,无法实例化模块starter.controllers: 错误:[$ injector:nomod]模块' starter.controllers'不可用!您要么错误拼写了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。
Controller.js
angular.module('starter.controllers', [])
.controller('NewCtrl', function($scope) {})
.controller('LoginCtrl', function($scope, Chats) {
})
.controller('CameraCtrl', function($scope, $cordovaCamera) {
document.addEventListener("deviceready", function () {
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 100,
targetHeight: 100,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false,
correctOrientation:true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
}, false);
});
.controller('OrderDetailCtrl', function($scope, $stateParams) {
})
.controller('ProcessCtrl', function($scope, $stateParams) {
})
.controller('DoneCtrl', function($scope) {
});
app.js
angular.module('starter', ['ionic','starter.controllers', 'starter.services'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tab.dash', {
url: '/new-order',
views: {
'tab-new': {
templateUrl: 'templates/new-order.html',
controller: 'NewCtrl'
}
}
})
.state('tab.chats', {
url: '/in-process',
views: {
'tab-inprocess': {
templateUrl: 'templates/process.html',
controller: 'ProcessCtrl'
}
}
})
.state('tab.chat-detail', {
url: '/new-order/id',
views: {
'tab-new': {
templateUrl: 'templates/order-detail.html',
controller: 'OrderDetailCtrl'
}
}
})
.state ('login',{
url: '/login',
templateUrl: 'templates/login.html',
controller: 'LoginCtrl'
})
.state ('camera',{
url:'/camera',
controller:'CameraCtrl'
})
.state('tab.account', {
url: '/done',
views: {
'tab-done': {
templateUrl: 'templates/done.html',
controller: 'DoneCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/login');
});
的index.html
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-app="starter">
答案 0 :(得分:0)
您必须在应用脚本之前加载依赖项(在本例中为controllers.js)。所以最后只需加载app.js