Friday 15 April 2011

AngularJS ng-required not working with variables -


I need a direct ng, but I can not do true or wrong hardcodes I need to use it in a variable , But angular does not recognize "truth".

  & lt; Div ng-app ng-init = "test = true" & gt; & Lt; Div & gt; Both have NG-required = "true" & lt; Br / & gt; As a hardcode string literally, through a variable & lt; Br / & gt; Inspect them, there is no need! & Lt; / Div & gt; & Lt; Form name = "myForm" & gt; & Lt; Input type = "text" ng-required = "{{test}}" /> & Lt; Input type = "text" ng-required = "true" /> & Lt; / Form & gt; & Lt; / Div & gt;   

How can I work it out?

  & lt; Input type = "text" ng-required = "{{test}}" />   

You do not need to collect test here because you want to evaluate the value of the test, just remove the curly braces and it should work. .

No comments:

Post a Comment