0
我正在開發我的第一個小而簡單的應用程序與平均堆棧,但我有一些角度問題(我正在學習它),我已經找到一個答案沒有找到解決方案。 我有下面的文件在我的項目,但是當我去到本地主機:3000我收到此錯誤:無法實例化模塊 - 角
Failed to instantiate module hiking-app due to:
[$injector:nomod] Module 'hiking-app' 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.
我的文件:
ROUTER.JS
angular.module("hiking-app",[]).
config(function($routeProvider)
{
$routeProvider.
when('/alpi',
{
template : 'partials/basic-template.html', controller:AlpiCtrl
}).
when('/ande',
{
template : 'partials/basic-template.html', controller:AndeCtrl
}).
when('/dolomiti',
{
template : 'partials/basic-template.html', controller:DolomitiCtrl
}).
otherwise({redirectTo:'/home', template:'partials/home.html'});
});
function MainCtrl($scope, $location)
{
$scope.setRoute = function(route)
{
$location.path(route);
}
}
function AlpiCtrl($scope)
{
$scope.title = "ALPI";
$scope.body = "test ";
}
function AndeCtrl($scope)
{
$scope.title = "ANDE";
$scope.body = "test ";
}
function DolomitiCtrl($scope)
{
$scope.title = "DOLOMITI";
$scope.body = "test ";
}
INDEX.HTML
<html ng-app="hiking-app">
<head>
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css"/>
<link rel="stylesheet" href="css/main.css" />
<script src="app.js"></script>
<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/angular-route/angular-route.js"></script>
<script src="router.js"></script>
</head>
<div id="header"><img src="img/hiking-header.png" /></div>
<body ng-controller="MainCtrl">
<nav class="navbar navbar-default" ng-controller="NavigationController">
<table id="menutable">
<tr>
<td><a ng-click="setRoute('alpi')">Alpi</a></td>
<td><a ng-click="setRoute('ande')">Ande</a></td>
<td><a ng-click="setRoute('dolomiti')">Dolomiti</a></td>
<td><a ng-href="{{himalaya}}">Himalaya</a></td>
<td><input type="button" value="REGISTRATI" id="btnreg"></input></td>
<td><input type="button" value="LOGIN" id="btnlogin"></input></td>
</tr>
</table>
</nav>
<div class="container">
<div ng-view></div>
</div>
</nav>
</body>
</html>
BASIC-TEMPLATE.HTML
<h1>{{title}}</h1>
<p>{{body}}</p>
APP.JS
var express = require('express'),
app = express();
var server = require('http').createServer(app);
var mongoose = require('mongoose');
app.use('/app', express.static(__dirname));
app.use('/node_modules', express.static(__dirname + "/node_modules"));
app.use('/img',express.static(__dirname + "/img"));
app.use('/css',express.static(__dirname + "/css"));
server.listen(3000);
mongoose.connect('mongodb://127.0.0.1/mountains', function(err){
if(err){
console.log(err);
} else{
console.log('Connected to mongodb!');
}
});
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
你是對的,但我仍然得到同樣的錯誤 – splunk
@GreenMamba我可知道什麼是'router.js'?並在控制檯中獲得哪些錯誤? –
我試圖創建一個導航菜單,當我點擊一個鏈接(例如Alpi)時,它應該調用setRoute方法並在網頁中插入內容(標題和正文)。 完整的錯誤信息在這裏:http://justpaste.it/hiking-app-angular – splunk