我是 AngularJS 初学者开发人员,我正在构建简单的应用程序,但我遇到了问题
这是我的 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>
这是我的 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'));
这是我的简单demo
如何将ng-option上的数据输出为重复表单文本?提前致谢
最佳答案
我也是 Angular 的新手,但这在过去几天对我很有用。
<div ng-controller="TabsDemoCtrl">
<label>Category</label>
<select class="form-control" >
<option ng-repeat="category in categories">{{category.name}}</option>
</select>
</div>
关于javascript - 如何将 ng-options 更改为 ng-repeat?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34647435/