我尽可能地检查我的JS,但我似乎无法找到任何明显的问题。我得到以下内容:
Uncaught Error: [$injector:modulerr] Failed to instantiate module careApp due to:
Error: [$injector:nomod] Module 'careApp' 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.
我确保我也使用了正确的模块和依赖项。似乎没有任何错误或不合适的地方。
我认为它与我的JS中的$routeProvider
部分有关...
'use strict';
(function() {
var AppCtrl;
AppCtrl = function() {
function AppCtrl($scope) {
$scope.list = [{
label: 'Main Menu',
icon: 'fa fa-home fa-fw 4x',
link: '#/homePage',
move: function() {
console.log("HOME");
}
}, {
label: 'Patient',
icon: 'fa fa-user fa-fw 4x',
link: '#/pCredential',
move: function() {
console.log("PATIENT");
}
}, {
label: 'Technician',
icon: 'fa fa-user-md fa-fw 4x',
link: '#/tLogin',
move: function() {
console.log("TECHNICIAN");
}
}, {
label: 'Administrator',
icon: 'fa fa-cogs fa-fw 4x',
link: '#/aLogin',
move: function() {
console.log("ADMINISTRATOR");
}
}];
}
return AppCtrl;
}();
// Declare app level module which depends on views and components
angular.module('careApp', [
'ngRoute',
'ngMaterial',
'ngAria',
'ngAnimate'
])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('#/homePage' {
template: '<p>WELCOME HOME!</p>'
}).
when('#/pCredential' {
template: '<p>INSERT CREDENTIALS INTO NODE.</p>'
}).
when('#/tLogin' {
template: '<p>PLEASE LOGIN TO THE TECHNICIAN PAGE.</p><p>GET CREDENTIALS FROM OWNER.</p>'
}).
when('#/aLogin' {
template: '<p>ADMINISTRATOR ACCESS.</p>'
})
//load default page on page refresh
.otherwise({
redirectTo: '/appLaunch'
});
}])
.controller('AppCtrl', ['$scope', AppCtrl]);
}());
当前小提琴:https://jsfiddle.net/Miega/mowwckze/3/
非常感谢任何帮助。
答案 0 :(得分:2)
您在所有.when
路线定义中的第一个参数后都缺少逗号。
$routeProvider
.when('#/homePage', {
template: '<p>WELCOME HOME!</p>'
}).
when('#/pCredential', {
template: '<p>INSERT CREDENTIALS INTO NODE.</p>'
}).
when('#/tLogin', {
template: '<p>PLEASE LOGIN TO THE TECHNICIAN PAGE.</p><p>GET CREDENTIALS FROM OWNER.</p>'
}).
when('#/aLogin', {
template: '<p>ADMINISTRATOR ACCESS.</p>'
})