【发布时间】:2020-03-31 08:35:31
【问题描述】:
当我在浏览器上加载应用程序时,我想为其添加一个基本 URL。
我的 expressJs 配置是:
App.js
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(expressSanitizer());
app.use(express.static(__dirname + '/webapp'));
app.engine('html',require('ejs').renderFile);
app.set('view engine', 'html');
AngularJs 路由器配置:
index.js
$urlRouterProvider
.when('','login')
.when('/','login')
.otherwise(function($injector, $location){
var state= $injector.get('$state');
state.go('error', { url: $location.path() }, { location: true });
});
//define states
$stateProvider
.state('/',{
templateUrl: 'public/login.html',
controller: 'login',
authenticated:false
})
.state('login',{
url: '/login',
templateUrl: 'public/login.html',
authenticated:false
// controller: 'login'
// template: '<h1> Routing to login page </h1>'
})
我希望它类似于我们在 Apache Tomcat 中部署应用程序时的情况。
目前,当我启动服务器时,url 类似于localhost:8080/login,但我希望它为localhost:8080/CRM/login
【问题讨论】:
标签: node.js angularjs express angular-ui-router