How ng-message is connected to model, and how can I show the message using ng-message?

前端 未结 3 1268
盖世英雄少女心
盖世英雄少女心 2021-01-01 19:13

In this plunk the objective is to show an error message based on validation in the controller (instead of the built-ins required or min-length). Th

3条回答
  •  忘掉有多难
    2021-01-01 19:44

    The more proper way to do this in controller is to use $setValidity

    if(a !== b){
        form.inputName.$setValidity('custom-err', false);
    } else {
        form.inputName.$setValidity('custom-err', true);
    }
    
    form.$setSubmitted();
    

提交回复
热议问题