我得到一些
JSON格式的数据,其中一些键中有空格:
原文链接:https://www.f2er.com/angularjs/141448.html[ { "PlainKey": "SomeValue","Spaced Key": "SomeValue" },{ "PlainKey": "SomeValue2","Spaced Key": "SomeValue2" } ]
这发生在某个时刻:
$http.get('https://dl.dropBoxusercontent.com/u/80497/htmlTesting/properties/credits.properties' + '?callback=JSON_CALLBACK').then(function (data) { $scope.credits = data.data; },function (error) { $scope.errorOccured = true; console.log("Error:"); console.log(error); });
然后使用ng-repeat来显示它,并订购:
<select ng-model="corder"> <option value="PlainKey">Plain Key</option> <option value="Spaced Key">Spaced Key</option> </select> <li ng-repeat="credit in credits | orderBy:corder" > ..... </li>
这不起作用(我得到一个例外)
(PlainKey可以工作,因为没有空格).
我也尝试将值放在’:
<select ng-model="corder"> <option value="'PlainKey'">Plain Key</option> <option value="'Spaced Key'">Spaced Key</option> </select>
这似乎改变了顺序,但不正确.
我错过了什么?
谢谢!