0
我正在創建一個應用程序,而且我沒有在控制器範圍內獲得ng-model值。當頁面正在加載時,它將發送給控制者,但是價值從ng-model未定義到控制器的範圍。 這裏是HTML:ng-model不在範圍內
<form class="form-signin" id="loginForm">
<h2 class="form-signin-heading">Por Favor Ingresar</h2>
<label for="matricula" class="sr-only">Matricula</label>
<input type="text" ng-model="matricula" id="matricula" class="form-control" placeholder="Matricula" required="" autofocus="">
<label for="inputPassword" class="sr-only">Contraseña</label>
<input type="password" ng-model="contrasena" id="inputPassword" class="form-control" placeholder="Contraseña" required="">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="acuerdate" value="remember-me"> Acuérdate de mí
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" ng-click="login.getAuthenticate()" type="submit">Ingresar</button>
</form>
控制器低於:
angular.module('myApp')
.controller('LoginController', LoginController);
LoginController.$inject = ["$scope",'LoginService','Common.Services.Navigation','Common.Constants.Routes'];
function LoginController($scope,loginService,navigate,route){
var login =$scope;
var request ={'matricula':login.matricula}; /***Here the Value is undefined**/
login.getAuthenticate = getAuthenticate;
function getAuthenticate(){
loginService.doRequest(request).then(function() {
navigate.navigate(route.routes.cardDetails);
}),function (error) {
//Handle the Error Handle
//Its pending to show Device native alert message
//or TOAD MESSAGE
};
}
}
請幫我你的建議。
*總是..always ..always *使用對象在'NG-model' ...當你使用童工範圍將打破綁定一個原始的 – charlietfl