我的后端ruby文件business_integrations
中有一个json值数组。
json值的代码是
def self.all
@_all ||= [
{
name: 'Google Analytics',
logo: 'ga.png',
category: 'Web Analytics',
link: '/businesses/%{business_id}/google_analytics_settings_change'
},
{
name: 'Google Search Console',
logo: 'search_console.png',
category: '',
link: '/businesses/%{business_id}/google_search_console_settings_change'
},
].map do |integration_hash|
BusinessIntegration.new(integration_hash)
end
我的控制器是
app.controller('IntegrationCtrl', ['$scope', '$routeParams',
'ContactIntegrationService', '$mdDialog',
function($scope, $routeParams, ContactIntegrationService, $mdDialog) {
$scope.business_id = $routeParams.business_id;
$scope.tracker_id = $routeParams.id;
$scope.integrationList = {};
$scope.config_id = {};
$scope.enable = [];
var _getListElement = function(suggestion, integrationList) {
var suggestionkey = _.keys(suggestion);
var integrationkey = _.keys(integrationList);
var item = _.intersection(suggestionkey, integrationkey);
var suggestionList = _.omit($scope.suggestion, item);
$scope.empty = _.isEmpty(suggestionList);
};
}
]);
目前,我已将值硬编码到视图中
<div class="list-group-item">{ 'ng-show': 'filter.all || filter.webAnalytics' }
<div class="row-picture">
<img />{:alt => "icon", :src => "#{image_path 'integrations/google_analytics.png'}"}</div>
<div class="row-content">
<div class="least-content">
<a class="btn btn-raised btn-warning mt-xs n">{'ng-href': "{{free_service ? '' : '/businesses/'+ current_business+'/google_analytics_settings_change'}}",
'ng-class': "{'btn-success': !biz.google_analytics_id, 'btn-warning': biz.google_analytics_id}", 'ng-disabled': 'free_service'}
{{biz.google_analytics_id ? 'Manage':'Connect'}}</a>
</div>
<h4 class="list-group-item-heading">Google Analytics</h4>
</div>
<hr class="mg-bt" />
</div>
我可以使用ng-repeat在视图中显示json数组吗?如何显示json数组?提前谢谢。