的代码看起来像 HTML:
<div class="col-sm-9">
<div class="container login">
<h1>User Login</h1>
<p>Please login below, if you have forgotten your password please <a href="/index.html#/resetpassword"><b>Click Here</b></a> to reset it.</p>
<form>
<div class="row">
<div class="col-sm-6 form-group">
<label for="email">Email Address</label>
<input class="form-control input-lg" type="email" id="inputEmail" required ng-model="user.email" placeholder="Enter your email">
</div>
<div class="col-sm-6 form-group">
<label for="password">Password</label>
<input class="form-control input-lg" type="password" required ng-model="user.password" placeholder="Enter your password">
</div>
</div>
<div ng-show="IsLoginFailure">
<p><span class="error"><b>Error:</b>Your emailId or password is wrong </span></p>
</div>
<br />
<button class="btn btn-grove-one btn-lg btn-bold" type="submit" ng-click="login()">Login</button>
</form>
<br />
<div class="clearfix"></div>
</div>
</div>
JS
.controller('LoginCtrl', ['$scope', '$http', '$rootScope', '$location', '$route', function ($scope, $http, $rootScope, $location, $route) {
$scope.login = function() {
$http({
method: 'POST',
url: 'http://site/api/login',
data: $scope.user
}).success(function (response) {
$location.path(Your Path);
$route.reload();
});
}).error(function() {
$scope.IsLoginFailure = true;
})
}
}])
谢谢,但这听起来不像一个安全的URL给我:任何人都可以直接转到AngularJS应用程序的url('YourPath'在你的代码中)并检索html和js而无需登录。 – icecrime