I am using angular ui router. The router seems to be working on the index.html homepage. But any other navigation does not work.
Here is my stateprovider angular:
var app = angular.module('myApp', ['ui.router']); app.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise("/"); $stateProvider .state("home", { url: "/", templateUrl: "../partials/home/index.html" }) .state("login", { url:"/login", templateUrl: "../partials/account/login.html" }) .state("register", { url: "/register", templateUrl: "../partials/account/register.html" }) .state("values", { url: "/values", templateUrl: "../partials/test/values.html" }) ; });
HTML in my main index.html:
<div class="container"> <div ui-view></div> </div>
When I navigate the localhost: 8080 / login page, I get the following:
I would have thought that I would not even see this page if it could not find it. You should not redirect me back to "/" because of $ urlRouterProvider.otherwise (). Also, although the pattern url / partials / account / login.html is Exist.
I'm a little new to node.js and I'm curious if the file server for notes is trying to route and drag my angular one? I use an http server, which is probably the most common.
I also use Express Node if this helps. And here is the code for app.js, where, I think, the problem may arise from:
var express = require('express'); var path = require('path'); var favicon = require('static-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var routes = require('./routes/index'); var users = require('./routes/users'); var app = express(); // view engine setup app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); app.use(favicon()); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded()); app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', routes); app.use('/users', users); /// catch 404 and forward to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); err.status = 404; next(err); }); /// error handlers // development error handler // will print stacktrace if (app.get('env') === 'development') { app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: err }); }); } // production error handler // no stacktraces leaked to user app.use(function(err, req, res, next) { res.status(err.status || 500); res.render('error', { message: err.message, error: {} }); }); module.exports = app;