2017-01-21 42 views
0

我有这样的代码和每一个我输入“本地主机:3000 /第1页”时什么也没发生,我得到拿不到/第1页,这是代码..我声明的状态没有被拾起?

var module = angular.module('ngFirstApp',['ui.router']); 

module.config(function($stateProvider, $urlRouterProvider,$locationProvider) { 

    $stateProvider 
     .state("home",{ url: "/", template: "This is home" }) 
     .state("page1",{ url: "/page1", template: "this is page"}); 

    // Prety the URL 
    $locationProvider.html5Mode({enabled:true,requireBase: false}); 
    $urlRouterProvider.otherwise("/"); // always declare this for any URL that might be typed 

}); 

请即时通讯失去了我的脑海里,怎么来的时我把一个乱码网址它不需要我回到“/”状态?怎么了!??即时通讯这个洙沮丧..小时,寻找答案..小时

UPDATE: 我的继承人server.js代码,以及它是否会有所帮助,如果youre想知道如果我添加了UI的路由器,我做在我的HTML和双重检查开发工具网络选项卡没有错误..感到非常沮丧。

var express = require('express'); 
var app  = express(); 
var path = require('path'); // native js node path 

// set routing to ejs and change its default view folder 
app.set('view engine','ejs'); 
app.set('views',path.resolve(__dirname,'client','views')); 

// serve static files 
app.use(express.static(__dirname + '/client')); 

// set our main ejs view index file 
app.get('/',function(req, res){ 
    res.render('views/index');// use the render to use ejs templating 
}) 

// make app listen to port 3000 or any port 
app.listen(3000, function(){ 
    console.log('Server is running... at port: '+ 3000); 
}) 
+1

检查控制台日志中是否有错误 –

+0

尝试localhost/page1是否工作。如果工作,那么你有CORS问题。 – digit

+0

我检查控制台它只是一个正常的[HTTP/1.1 404 Not Found 7ms]错误...我剥离代码裸露,仍然不知道为什么它不拿起page1 url ... ughhaa .. @digi什么是CORS问题? – Chopnut

回答

1

我可以看到你的应用程序部署在local server然后根据您所使用的服务器的类型,您只有它导航到应用程序的页面之前,指定web application name

假设您部署的应用程序为'movies',那么localhost:3000/movies将带您进入电影目录的默认索引,即您的Web应用程序已初始化的位置。

所以在你的情况下尝试localhost:3000/yourdirectory/page1这可能会帮助你!

+0

欢迎任何评论或建议!谢谢你有看看这个,我不会去任何地方只是试图解决这个问题..呃再次感谢 – Chopnut