javascript - Angular's ng-options work incorrect | Angularjs -
angular's ng-options works incorrect.
it must render select this:
<option value="1" label="not available">not available</option> <option value="3" selected="selected" label="available">available</option>
but not. value keys aren't match , selected tag doesn't work.
what i'm doing wrong here?
product model object db
object {id: "7", name: "some name", category_id: "1", img_big: "uploads/products/5552f2ba31694@big.jpeg", img_thumb: "uploads/products/5552f2ba31694@thumb.jpeg"…}
isavailable object
$rootscope.isavailablescope = [ { status: 1, name : 'not available' }, { status: 3, name : 'available' } ]
html
<select class="form-control" ng-model="product.is_available" ng-options="isavailable.status isavailable.name isavailable in isavailablescope" required> <option value="">choose</option> </select>
change $rootscope
$scope
. you're in controller , within it's scope.
$rootscope.isavailablescope = [ { status: 1, name : 'not available' }, { status: 3, name : 'available' } ]
to ...
$scope.isavailablescope = [ { status: 1, name : 'not available' }, { status: 3, name : 'available' } ]
Comments
Post a Comment