我覺得我正在失去主意,因爲答案應該很簡單,我對angular和nodejs很陌生,我試圖製作一個將它們結合在一起的應用程序都。Angular和NodeJS模塊'foo'不可用
"Error: [$injector:nomod] Module 'myApp' 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."
公共/控制器/ HomeController的:
(function() {
'use strict';
angular.module('myApp').controller('homeController', homeController);
function homeController() {
var vm = this;
vm.fillerData = "FillerData"
}
})();
公共/ index.html中:
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Dit is de index</title>
<script src="res/js/angular.js" type="text/javascript" defer="defer"></script>
<script src="controllers/homeController.js" type="text/javascript" defer="defer"></script>
</head>
<h1>What</h1>
<body ng-controller="homeController as homeCtrl">
{{ homeCtrl.fillerData }}
</body>
</html>
路由器/ index.js:
var router = require('express').Router();
router.get('/index', function (req, res) {
res.sendfile('public/index.html');
});
router.get('/home', function (req, res) {
res.sendfile('public/home.html');
});
module.exports = router;
和/服務器。 js:
var express = require('express');
var app = express();
var routes = require('./router');
app.use(express.static(__dirname + '/public'));
app.use('/', routes);
require('router/index.js')(app);
app.listen(3000);
console.log("App listening on port 3000");
所有必需的包已經裝好,任何幫助,將不勝感激
我只能說「哇...」。這解決了這一切,謝謝我感謝他。 – Laurens
@woodsprite希望你看到了我的答案:P – Sajeetharan
是的,但Suren早了一分鐘,我投票支持你! – Laurens