1
如果我有這樣的:是否有可能通過對象的指定列表NG-重複屬性
$scope.listOfAttributes = ["someThings", "yetMoreThings"]
$scope.whatever = {
someThings: "stuff",
otherThings: "Also stuff",
yetMoreThings: "still stuff"
};
是否有可能做這樣的事情:
<ul>
<li ng-repeat="thing in listOfAttributes">{{ whatever.thing }}</li>
</ul>
否則我將不得不處理它之前像這樣:
$scope.generatedObject = {}
$scope.listOfAttributes.forEach(function(thing)){
$scope.generatedObject[thing] = $scope.whatever[thing];
});