Ich mache eine angularjs App, in der ich Express als Backend bin. Das Problem, das ich gegenüberstelle ist nicht in der Lage, zwischen meinen Html-Seiten wechseln.Kindly Hilfe, ich Ich habe viele Tutorials ausprobiert, aber keiner von ihnen hat funktioniert. Ich denke, es muss ein Problem in dem Pfad geben, den ich bereitstelle. Hier ist meine server.js `Seitenänderung wird nicht in angularjs bei der Verwendung von routeProvider
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mysql = require('mysql');
var ejs = require('ejs');
var urlencodedParser = bodyParser.urlencoded({extended:false});
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'test'
});
connection.connect();
app.use(express.static('public'));
//app.set('views', __dirname + 'views');//this is used because res.render('../template/goto_page_options.html', {values : city});
//was not able to render the view
app.set('view engine', 'ejs');
app.use(bodyParser.json());
app.get('/', function(req, res) {
var path = require('path');
res.sendFile(path.resolve('../template/login.html'));
console.log("WOW");
})
app.get('/home', function(req, res) {
var path = require('path');
res.sendFile(path.resolve('../template/home.html'));
console.log("home requested");
})
` Das ist mein app.js
app.config(['$routeProvider', function ($routeProvider){
$routeProvider
.when('/',{
redirectTo: '/login'
})
.when('/home',{
templateUrl:'home.html'
})
.when('/employee',{
templateUrl:'employee.html'
})
.when('/login',{
templateUrl:'login.html'
})
.otherwise({ redirectTo: '/login' });
}]);
Das ist mein index.html
<body ng-app="starter">
<div ng-view></div>
<script src="http://localhost/try/www/js/app.js"></script>
<script src="http://localhost/try/www/js/server.js"></script>
</body>
meine Verzeichnisstruktur ist
templates
--login.html
--home.hml
js
--app.js
index.html
in Ihrem Verzeichnis sturcture wo employee.html Datei in Ihrem Vorlagen-Ordner ist –
Wo das für $ routeProvider die refrence ist? –