我是Angularjs的新手。我正在开发小网页。我有登录和注册表格。我在一个主控制器中定义了登录和注册js
代码。如果用户是新用户,我已经在登录名下面定义了链接,点击它就可以重新定向到另一个html页面。 URl正在路由,但我的js code
不是
回应。我试图纠正这个错误,但我无法实现它。
请让我知道我做了什么错误。任何帮助/建议都非常感谢。
Html代码:
<form ng-submit="log(userCred)" name="logform" method="get" ng-init="logform = {}"><br/><br>
<div>
<label form="emailinput"><b>Email</b></label>
<input type="email" class="form-control" name="uname" id="emailinput" placeholder="you@example.com" ng-model="userCred.username" >
</div>
<div >
<label form="pwdinput"><b>Password</b></label>
<input type="password" class="form-control" name="pwd" id="pwdinput" placeholder="*******" ng-model="userCred.password">
</div>
<div>
<button type="cancel" class="btn" ng-click="toggle_cancel()">Cancel</button>
<input type="submit" class="btn btn-primary" value="Login" >
</div>
<br/>
</form>
<div ng-controller="footerctr">
<p>{{foter}}<a href="home"> Here </a></p>
</div>
AngularJS代码:
var app = angular.module('logapp',['toastr','ngRoute']);
app.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/login',{
templateUrl : "login.html",
controller : "credientials"
})
.when('/home',{
templateUrl : "home.html",
controller : "homectrl"
})
.when('/practice',{
templateUrl : "practice.html",
controller : "practicectrl"
});
$routeProvider.otherwise({ redirectTo: '/login'});
}]);
控制器:
1. app.controller('credientials',['$scope','$route','$rootScope','$window','$location','$http','toastr','Authentication',function($scope,$route,$rootScope,$window,$location,$http,toastr,Authentication)
2. app.controller('homectrl',function($scope){});
app.controller('head',function($scope){
$scope.hometitle = "Create your account here. It's take only a minute."
});