I try to create a simple SPA application and in html file i have errors like: "failed to load resource: angular.js", "failed to load resource: angular-route.js", "failed to load resource: myApp.js" and similar. Like the path is wrong but is not.
This is a part of my server in Node:
var express = require('express');
var path = require("path");
var app = express();
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var bower = require('bower');
var userRouter = require('../app/controller/users');
var aplikacijaRouter = require('../app/controller/aplikacije');
var dogadjajRouter = require('../app/controller/dogadjaji');
// connection with mongodb
mongoose.connect('mongodb://localhost/pracenje_gresaka_db')
// configuration of bodyParser()
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
var port = process.env.PORT || 8181;
//view of html files
app.get('/', function(req, res){
res.sendFile(path.join(__dirname + "/public/" + "example1.html" ));
});
app.get('/signup', function(req, res){
res.sendFile(path.join(__dirname + "/public/" + "signup.html" ));
});
app.get('/login', function(req, res){
res.sendFile(path.join(__dirname + "/public/" + "login.html" ));
});
This is a html example1 with paths for angular:
<html>
<head>
<script type="text/javascript" src="../bower_components/angular/angular.js"></script>
<script type="text/javascript" src="../bower_components/angular-resource/angular-resource.js"></script>
<script type="text/javascript" src="../bower_components/angular-route/angular-route.js"></script>
<script type="text/javascript" src="myApp.js"></script>
</head>
<body ng-app="app">
<h1>
Example
</h1>
<div ng-view> </div>
</body>
</html>
And this is a myApp.js but i never reach it:
(function(angular) {
var helloController = function ($scope) {
$scope.message = "Hello from the controller!";
};
var app = angular.module('app', ['ngRoute','ngResource']);
app.controller('helloCon', helloController);
app.config(function($routeProvider) {
$routeProvider
.when('/main',{
templateUrl: 'primer01-entries.html',
controller: 'helloCon'
})
.otherwise({
redirectTo:'/main'
});
});
})(angular);
Image of error Thanks for help!