Reputation: 99
I'm beginner AngularJS developer, and I'm building simple app but I have a problem
This is my Html
<div ng-app="MyApp">
<div ng-controller="TabsDemoCtrl">
<div ng-controller="TabsDemoCtrl">
<label>Category</label>
<select class="form-control" ng-model="product.category" ng-options="category as category.name for category in categories"></select>
</div>
<label>how to change ng-options to be ng-repeat ?my achieve is to be like this</label>
<input type="text" class="form-control" value="custom">
<input type="text" class="form-control" value="non-custom">
</div>
</div>
and this is my Js
angular.module('MyApp', [
'ui.bootstrap']);
(function(MyApp) {
'use strict';
MyApp.controller('TabsDemoCtrl', ['$scope', function($scope) {
// categories
$scope.categories = [
{
name:'custom',
templateAttribute: [
{attribute: 'material'},
{attribute: 'soles'},
{attribute: 'size'}
]
},
{
name:'non-custom',
templateAttribute: [
{attribute: 'material'},
{attribute: 'soles'},
{attribute: 'size'}
]
}
];
}]);
})(angular.module('MyApp'));
this is my simple demo
How to output data on ng-option to be repeat form text? Thank advance
Upvotes: 1
Views: 210
Reputation: 3756
Try this. this may help you
<select ng-options="catagory.name as catagory.name for catagory in categories" ng-model="categoryName"class="form-control" name="categoryName">
<option value="">Select Category</option>
</select>
Upvotes: 0
Reputation: 1111
I am new to Angular as well, but this has worked for me the last few days.
<div ng-controller="TabsDemoCtrl">
<label>Category</label>
<select class="form-control" >
<option ng-repeat="category in categories">{{category.name}}</option>
</select>
</div>
Upvotes: 1
Reputation: 25352
Try like this
<div ng-repeat="category in categories">
<input type="text" class="form-control" ng-model="category.name">
</div>
Upvotes: 0