我使用node.js与express和Angularjs来建立我的网站的网页, 但我在控制台中得到以下输出 看起来程序无法找到我的脚本文件位于程序找不到我的脚本文件
GET http://localhost:3000/images/entet_gauche.gif 404 (Not Found)
GET http://localhost:3000/js/app.js
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.8/$injector/modulerr?p0=MetaStore&p1=Error%…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.8%2Fangular.min.js%3A17%3A350)
这似乎是程序无法找到位于 我的脚本文件,什么是错的路径?
的index.html
<body ng-app="MetaStore">
<a class="navbar-brand" href="#">
<img alt="Brand" src="./images/entet_gauche.gif">
</a>
<div ng-controller="produContr" class="container">
<div class="container-fluid">
<div class="row">
<div ng-repeat="product in products | filter:search:strict" class="col-sm-3">
<h3> {{product.name}} </h3>
<p> {{product.content}} </p>
<p><strong>Prix : </strong> {{product.prix}} DH</p>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="/js/app.js"></script>
</body>
JS/app.js
变种应用= angular.module( 'MetaStore',[]); app.controller( 'produContr',函数($范围,$ HTTP,$间隔){
})
server.js
var express = require("express");
var mysql = require("mysql");
var app = express();
var connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "angularjsDB"
});
connection.connect(function(error) {
if (error) {
console.log("Problem with MySQL" + error);
} else {
console.log("Connected with Database");
}
});
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.get('/load', function(req, res) {
connection.query("SELECT * from product", function(err, rows) {
if (err) {
console.log("Problem with MySQL" + err);
} else {
res.end(JSON.stringify(rows));
}
});
});
app.listen(3000, function() {
console.log("It's Started on PORT 3000");
});
更新: 这是我的目录结构:
index location -> (folder/index.html) ...
server location -> (folder/server.js) ...
app location -> (folder/js/app.js) ...
picture location ->(folder/images/entet_gauche.gif)
感谢您的关注和考虑看看
尝试'src =“images/entet_gauche.gif”'和'src =“// images/entet_gauche.gif”'。只是出于好奇! – surajck
不工作我的朋友 – user3514348
你可以发布你的目录结构看起来像什么吗? – lhoworko