У меня есть массив значений json в моем бэкэнд-файле ruby business_integrations
.
Код для значений 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>
Могу ли я отобразить массив json в моем представлении, используя ng-repeat?Как я могу отобразить массив JSON?Заранее спасибо.