ng-required无法正常工作

时间:2018-03-01 00:06:44

标签: angularjs required ng-required

我的TextEdit上有一个必需的条件。

当我检查谷歌检查屏幕时,我可以看到我的情况正常 (Test.Pack.substring(0,2)!='RR')

但是,我发现即使ng-required = false,它仍然在元素上有一个required =“required”属性。

我的代码和截图在下面。有什么想法吗?

You can see the required and ng-required in the picture

df['New']=(df.fruit.str.replace(' ','').str.get_dummies(',')+df.choice.str.get_dummies()).gt(1).any(1).astype(int)
df
Out[728]: 
   ID     choice             fruit  New
0   1     orange     apple, banana    0
1   2     orange             apple    0
2   3      apple             apple    1
3   4  pineapple         pineapple    1
4   5      apple  apple, pineapple    1
5   6     orange            orange    1
6   7     orange     apple, orange    1
7   8     orange            orange    1
8   9     banana            banana    1
9  10     banana      apple, peach    0

1 个答案:

答案 0 :(得分:1)

传递给ng-required的值应该是boolean.So更改此

 <div>
                <input ng-model="Test.LM" ng-required="{{Test.Pack.substring(0,2) != 'RR'}}">
    </div>

<div>
            <input ng-model="Test.LM" ng-required="Test.Pack.substring(0,2) != 'RR'">
        </div>