模拟做了一个登陆流程
HTML代码
<body style="padding: 10px" ng-app='app'>
<div ng-controller="Ctrl">
<input type="text" ng-model="user.uname" />
<input type="text" ng-model="user.pwd" />
<div class="button" ng-click="login()">登陆</div>
<div class="alert-box" ng-show="errormsg.length>0">
{{errormsg}}
</div>
</div>
</body>
JavaScript代码
angular.module("app",[])
.controller('Ctrl',function($scope){
$scope.user = {
uname:'',
pwd:''
};
$scope.errormsg = '';
$scope.login = function(){
//console.log($scope.user.uname+'-'+$scope.user.pwd);
if($scope.user.uname == 'admin' && $scope.user.pwd == '123456'){
$scope.errormsg='登录成功!'
}else{
$scope.errormsg='用户名或者密码错误'
}
}
})