我使用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