简体   繁体   中英

angular ng-options required not working with slim template

I google it and no luck,so I need some help.

This is a problem when using angularjs, the ng-required not working.I used BS3,slim template ,rails as backend. The input element working fine.

form ng-submit="load()"
  input ng-required="true"
  select ng-model="m" ng-options="m for m in ['am','pm']"  ng-required="true"
  button.btn type="submit" load

ng-required="m" and required="" also not working

Sorry for my bad english and poor problem :<

You should use required instead of ng-required like this

form ng-submit="load()"
   input ng-required="true"
   select ng-model="m" ng-options="m for m in ['am','pm']"  required
   button.btn type="submit" load

Here is a working jsFiddle http://jsfiddle.net/vikasgoyalgzs/qQdu5/

You should use ng-required only when you want to get the value of required from a scope variable or function.

eg

//In view
ng-required="myScopeVariable"

//In controller
$scope.myScopeVariable = true;

or

//in View
ng-required="myScopeFunction()"

//in controller
$scope.myScopeFunction = function () {
   // your logic goes here
   return true;
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM