我创建了一个应用程序,一个登录页面和一个这样的控制器:----->
--->在这里:)
// .../someController
use Symfony\Component\Process\Process;
class someController extends Controller
{
public function someAction()
{
$process = new Process('php app/console doctrine:migrations:migrate 20150914201128');
$process->run();
/.../
}
}
(function(){
'use strict';
angular
.module("loginApp",[])
.controller("loginCtrl",loginCtrl);
loginCtrl.$inject = ['$location','$scope','loginService'];
function loginCtrl($location,$scope,loginService){
var vm = $scope;
vm.login = login;
function login(){
var user = vm.user;
console.log(user);
};
}
})();
但是当我点击“login()”按钮时,什么也没发生。我不知道为什么。
答案 0 :(得分:0)
因为您不在控制器中直接使用示波器(好方法),所以必须在html中设置别名(loginCtrl作为登录名)。然后设置模型并使用别名作为前缀(login.user.username)调用ctrl-functions。
<body ng-app="loginApp" ng-controller="loginCtrl as login">
<div class="col-md-6 col-md-offset-3">
<h2>Login</h2>
<form name="form" ng-submit="login.login()" role="form" method="post">
<div class="form-group" ng-class="{ 'has-error': form.username.$dirty && form.username.$error.required }">
<label for="username">Username</label>
<input type="text" name="username" id="username" class="form-control" ng-model="login.user.username" required />
<span ng-show="form.username.$dirty && form.username.$error.required" class="help-block">Username is required</span>
</div>
<div class="form-group" ng-class="{ 'has-error': form.password.$dirty && form.password.$error.required }">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control" ng-model="login.user.password" required />
<span ng-show="form.password.$dirty && form.password.$error.required" class="help-block">Password is required</span>
</div>
<div class="form-actions">
<button type="submit" ng-disabled="form.$invalid || dataLoading" class="btn btn-primary">Login</button>
<img ng-if="dataLoading"/>
<a href="#/register" class="btn btn-link">Register</a>
</div>
</form>
</div>
...................
<!-- App -->
<script src="angular/scripts/login.router.js"></script>
<script src="angular/scripts/controllers/login/loginCtrl.js"></script>