javascript - How to use ng-init to select a default value in a select box when the ng-model and the ng-options are referencing different objects -
i have select box iterates on listofthings, , model has currentthing property. select box binds currentthing correctly.
however, can't ng-init set default value in listofthings currentthing. following isn't setting default value.
<select ng-options = "something something.name in controller.listofthings" ng-model = "controller.currentthing" ng-init = "something = controller.currentthing" ng-change = "controller.changething(controller.currentthing)"/> i output values of something , currentthing , they're same.
any ideas? thanks!
instead of using in dom should assign default value in controller
like:
$scopr.controller.currentthing = $scopr.controller.listofthings[0];// first element or need and no need
ng-init = "something = controller.currentthing"
Comments
Post a Comment