无法使用角度路由提供程序重定向
Unable to redirect using angular routeprovider
当我点击locahost:port/projectname/时无法重定向到signup.html页面时,我是angular i的新手
event尽管我在app.js中指定了singup的模板url,但我得到了404
但是当我点击locahost:port/projectname/signup.html文件打开时,我做错了什么吗?
我想在点击locahost:port/projectname/时获得signup.html
app.js
var app = angular.module('pollApp', ['ngRoute']);
app.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/Welcome', {
templateUrl: '/Welcome.html',
controller: 'submitCtrl'
})
.when('/', {
templateUrl: '/signup.html',
controller: 'submitCtrl'
})
.otherwise({
redirectTo: '/Welcome.html'
});
}]);
submitController.js
app.controller('submitCtrl',['$scope', '$http', '$location',
function ($scope, $http, $location) {
$scope.timeZones = [
{ label: '(GMT-09:00) Alaska', value: 'Alaska' },
{ label: '(GMT-08:00) Pacific Time (US & Canada)', value: 'Pacific Time (US & Canada)' }
];
$scope.submit=function() {
var userDetails=new Object();
userDetails.firstname=$scope.firstname;
userDetails.lastname=$scope.lastname;
userDetails.Companyname=$scope.Companyname;
userDetails.Email=$scope.Email;
userDetails.timezone=$scope.timezone;
console.log(userDetails);
$http({
method: 'POST',
data: userDetails,
url:'/mongopractise/rest/signup/userdata',
headers: {'Content-Type':'application/json'}
}).success(function(data, status, headers, config) {
console.log("success data"+JSON.stringify(data));
$scope.username=data;
$location.url('/Welcome.html').replace();;
}).
error(function(data, status, headers, config) {
console.log("Failure data"+data);
});
}
}]);
Signup.html
<html lang="en" ng-app="pollApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome!</title>
<script src="lib/angular.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<div class="container" ng-controller='submitCtrl'>
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-lg-3 control-label">First name:</label>
<div class="col-lg-8">
<input class="form-control" value="Jane" type="text" ng- model="firstname">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Last name:</label>
<div class="col-lg-8">
<input class="form-control" value="Bishop" type="text" ng-model="lastname">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Company:</label>
<div class="col-lg-8">
<input class="form-control" value="" type="text" ng-model="Companyname">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Email:</label>
<div class="col-lg-8">
<input class="form-control" value="janesemail@gmail.com" type="text" ng-model="Email">
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Time Zone:</label>
<div class="col-lg-8">
<div class="ui-select">
<select id="user_time_zone" class="form-control" ng-model="timezone" ng-options="timeZones as timeZones.label for timeZones in timeZones">
</select>
</div>
</div>
</div>
<div class="col-md-8">
<input class="btn btn-primary" ng-click='submit()' value="Save Changes" type="button"> <span class=""></span>
<input class="btn btn-default" value="Cancel" type="reset">
</div>
</div>
</form>
</head>
</html>
您的路由不包括'/projectname',我认为这是您的应用程序上下文。您需要将其包含在路由url中,以使其正常工作。
端口之后的任何路径都应在routeProvider
配置中。您的服务器应该提供项目名称文件夹,然后提供
.when('/', {templateUrl: '/signup.html',
controller: 'submitCtrl'
})
将按预期工作
相关文章:
- 在phonegap应用程序内部重定向不起作用
- 使用重定向来启动应用程序,并且仍然停留在asp.net中的同一页面中
- 如何重定向到我的html网站youtube嵌入视频打开在youtube应用程序
- Pinterest API应用程序处于开发模式(因此我可以使用http重定向)
- 无法使用角度路由提供程序重定向
- Github Pages中是否有一个配置允许您将所有内容重定向到单页应用程序的index.html
- AJAX上重定向视图的正确方式'成功'MVC应用程序中
- 如何在单击按钮重定向页面时显示加载程序gif
- 如何进行服务器端HTTP重定向更新引用程序(更改原始引用程序)
- Node.js express应用程序无法从dropzone.js回调进行重定向
- 当应用程序没有安装时,如何将用户重定向到(android,ios)市场
- 修改文档后如何重定向到应用程序的新页面
- 从chrome浏览器网址打开应用程序或使用javascript重定向到Google Play
- 路由提供程序否则重定向到不起作用
- 将节点应用程序中的表单数据重定向到 PHP 文件
- 在 mvc 应用程序中使用 href 属性重定向 asp.net 不起作用
- Firefox 插件中的 OnBeforeRequest URL 重定向(从 Chrome 扩展程序转换)
- FB应用程序请求重定向到画布页面而不是标签页
- 防止电子应用程序重定向时,拖放项目在窗口
- 从我的应用程序重定向到另一个站点