我正在尝试填充angularjs中的按钮下拉列表。
我收到以下错误。 "Unexpected end of expression: data.WotcSummary "|
我做错了什么。
js file:
WotcDashBoardModule.controller('WotcDashBoardController', ['$scope', 'WotcDashBoardModuleService', function ($scope, WotcDashBoardModuleService) {
var Ein = '95-000000';
WotcDashBoardModuleService.GetDashBoardSummary(Ein).then(function (response) {
$scope.Summary = response.data.WotcSummary;
//console.log($scope.Summary.Locations);
});
}]);
Locations是一个包含两个项目的数组
[Object, Object, Object]
0:Object
corporateId:1600
location:"California"
__proto__:Object
1:Object
corporateId:1600
location:"Atlanta"
__proto__:Object
2:Object
corporateId:1600
的位置:"波士顿"
HTML:
<div class="btn-group btn-toolbar btn-margin-left" style="float: right;" >
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
ALL LOCATIONS
<span class="caret"></span>
</button>
<div class="dropdown-menu">
<select name="ListLocations" class="form-control input-md"
ng-model="Locations"
ng-options="Locations.location for Locations in data.WotcSummary | track by Locations.location">
<option value=""> </option>
</select>
</div>
</div>
返回到视图的Business Object类是:
public class CompanyWotcBO
{
public int Id { get; set; }
public int IdUser { get; set; }
public int IdCandidate { get; set; }
public int DocsSubmitted { get; set; }
public int DocsRecieved { get; set; }
public string CompanyId { get; set; }
public string EIN { get; set; }
public string Error { get; set; }
public List<Location> Locations { get; set; }
public CompanyWotcBO()
{
Locations = new List<Location>();
}
}
public class Location
{
public int corporateId { get; set; }
public string location { get; set; }
}
这是返回的完整json对象::
Object {Id: 0, IdUser: 0, IdCandidate: 0, NewEmployees: 458, WotcScreened: 458…}
CompanyId:null
DocsRecieved:0
DocsSubmitted:0
EIN:null
Error:null
Id:0
IdCandidate:0
IdUser:0
Locations:Array[3]
0:Object
corporateId:1600
location:"95-3874566"
__proto__:Object
1:Object
corporateId:1600
location:"Atlanta"
__proto__:Object
2:Object
corporateId:1600
location:"Boston"
__proto__:Object
3:Object
corporateId:1600
location:"Chicago"
__proto__:Object
答案 0 :(得分:2)
您在ng-options
中不需要'|'
<select name="ListLocations" class="form-control input-md"
ng-model="Locations"
ng-options="Locations.location for Locations in data.WotcSummary track by Locations.location">
<option value=""> </option>
答案 1 :(得分:1)
将HTML更改为:
<compilation targetFramework="4.0">
<assemblies>
<add assembly="SomeNS.SomeDllName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=568C4712810GD043"/>
这应该有效