2016-08-03 91 views
0

我在与我想要一起工作的角度错误信息的麻烦财产“toLowerCase”。我想确保一封确认邮件的情况下不敏感不适用于最初的电子邮件地址。无法读取的不确定

在我的控制,我使用toLowerCase()过滤器....除了事实控制台不承认这一点,是给我的错误信息。

我的前端代码是

input-md{ type: "email", "ng-model" => "vm.form.email_confirmation", required: true, 'must-match' => 'register_form["vm-form-email"]', 'match-case-insensitive' => true, 'ng-hide' => 'vm.form.validated_email', autocapitalize: 'off' } 

和我的控制器,(最终问题出在哪里)

getMatchValue = -> 
    match = matchGetter($scope) 
    if (angular.isObject(match) and match.hasOwnProperty('$viewValue')) 
    match = match.$viewValue 
    match 

$scope.$watch getMatchValue, -> 
    ctrl.$$parseAndValidate() 
    return 

ctrl.$validators.mustMatch = -> 
    match = getMatchValue() 

    if $attrs.matchCaseInsensitive 
    ctrl.$viewValue.toLowerCase() is match.toLowerCase() 
    else 
    ctrl.$viewValue is match 
return 

如果有人可以看看这个,我将不胜感激!

回答

1

你应该确保你的对象不是undefined你可以使用angular.isDefined

确保你的对象不会是undefined

if (angular.isDefined(ctrl.$viewValue)){ 
    //Your Code 
} 
+0

我不知道,因为我如果我创建具有相同价值观的情况下提交电子邮件他们做的工作对象的定义,一切顺利的罚款。然而,它是在它已经有问题的对象的过滤器。 – kdweber89