angularjs - error populating dropdown with value angular -



angularjs - error populating dropdown with value angular -

when page loads prepoulate dropdown this

$scope.categories = [ 0, 1, 2, 3, 4 ];

here dropdown

<div> category: <select data-ng-model="category.currentcategory" data-ng-options="cat cat in categories">{{cat}} </select> </div>

i have need alter drop downwards value depending on data. this

$scope.cat = 1 preselect value of 1 doesnt work. doing wrong?

here error

typeerror: cannot read property 'currentcategory' of undefined

for data-ng-model should have "category" (you never define currentcategory attribute on category), , should set $scope.category=1, since model, not $scope.cat. when "cat cat in categories", cat local variable represents iteration of categories in options.

angularjs angularjs-directive angularjs-scope angularjs-ng-repeat

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -