2014-06-19 4 views
2

내 현재 빌드와 슈퍼 이상한 문제가 (각도 버전 1.2.16)각도 JS 및 입력 유형

컨트롤러 :.

app.controller('recoverController', function(
    $scope, 
    $rootScope, 
    $http, 
    $window, 
    $cookies, 
    $state 
){ 

    $scope.recoverAddress = 'hello'; 
}); 

보기 :

작품 :

<input type="text" ng-model="recoverAddress" /> 

실패 :

<input type="email" ng-model="recoverAddress" /> 
+0

가 오류를 받고, 아니면 그냥 빈 얼마나 각 작품 만 입력 유효한 이메일 등등 업데이트됩니까? – JoshSGman

+2

https://github.com/angular/angular.js/issues/1426 – HaukurHaf

답변

0

AngularJS는 입력 필드의 값이 유효성 검사를 통과 할 때만 모델에 바인딩합니다. 즉시 유효한 이메일 adress은 모델 바인딩 공급으로, 전문가들은이 here

<div ng-app ng-controller="testCtrl"> 
    <input ng-model="emailInput" type="email"> 
    <div>{{emailInput}}</div> 
</div> 

function testCtrl($scope) { 
    $scope.$watch('emailInput', function(newValue){ 
     console.log(newValue); 
    }); 
} 
+0

건배! hello를 [email protected]으로 변경하면 입력 유형 전자 메일이 예상대로 채워집니다. 그러나 나는보기에서 모델을 업데이트하는 데 여전히 문제가있다. 예를 들어 recoverAddress를 초기화 한 내 문장을 제거한 다음 올바른 이메일을 입력하고 제출을 누르면 여전히 콘솔에 정의되지 않은 상태로 기록됩니다. – aslan11

+0

여기를 참조하십시오 : http://jsbin.com/seyuz/1/edit – sylwester