从ng-grd in指令访问selectedItems

时间:2014-10-08 18:04:39

标签: angularjs ng-grid

您好,我有以下选项:

$ scope.mySourceSelections = [];

$scope.gridOptions = {
            data: 'formatSources',
            showSelectionCheckbox: true,
            enableCellSelection: true,
            enableRowSelection: true,
            multiSelect: false,
            selectedItems: $scope.mySourceSelections

   };

在我的指令中,我有一个模板可以在我的页面上嵌入HTML。 在我的div标签中,我有以下属性:
data-activity-source={{mySourceSelections}}

当页面呈现属性时: data-activity-source="[{"SourceName":"College of Letters & Science"}]"

要设置源代码,我需要语法为data-activity-source="College of Letters & Science"

当我将模板更改为:data-activity-source={{mySourceSelections[0].SourceName}}时 我收到以下两个错误:

GET /api/v1/activity/public?s=0&l=1&o=College%20of%20Letters%20&%20Science 400 (Bad Request) jquery-1.11.1.min.js?v=1412791216854:4
ERROR: getPublicActivitiesForSource : ajax : error 

我知道在尝试访问mySourceSelections的[0]索引时会发生这种情况。如何解决此问题并获取"来自学院的SourceName值的信息。科学"

1 个答案:

答案 0 :(得分:0)

看起来&符号会导致您的GET出现问题。尝试urlencoding请求。 &符号为%26,请尝试:

GET /api/v1/activity/public?s=0&l=1&o=College%20of%20Letters%20%26%20Science