如何将属性(在本例中为status.val
(分配给ng-repeat
中的变量,以便像上面使用的translation.status
一样对其应用转换?
我能做一些类似ng-repeat="status in statusList; a=status.val"
的事情吗?
<div>
<label for="status">{{translation.status}}</label>
<select class="form-control" id="status" ng-model="extraItemForm.status" ng-required="true">
<option ng-repeat="status in statusList" value="{{status.id}}">
{{status.val}}
</option>
</select>
</div>
您可以使用ng-init
html
<div ng-controller="MainCtrl">
<ul>
<li ng-repeat="mentor in mentors" ng-init="test = mentor">{{test}}</li>
</ul>
</div>
js
var app = angular.module('myApp', []);
function MainCtrl( $scope ) {
$scope.mentors = [ 'Jonathan', 'Nathan', 'Chris', 'Brian', 'Timothy' ];
}
jsfiddle
您可以在select
中使用ng-options
并添加translate:
<select ng-model="me.gender" ng-options="gender.name | translate for gender in genders"></select>
请参阅此链接上的示例