I need assistance with setting a background color for each element in a list retrieved from a JSON file. I want to utilize the getNumber() function to generate a random number and assign a corresponding color to each list element. How can I dynamically set the background-color of each div by invoking the getNumber() function?
HTML code-
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Radio Buttons</title>
<link href="//code.ionicframework.com/1.0.0-beta.12/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.min.js"></script>
</head>
<body ng-controller="MainCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Divs inside Div</h1>
</ion-header-bar>
<ion-content scroll="false">
<ion-scroll class="list" direction="y" style="height:100%">
<li class="item" ng-repeat="item in agendaDetails">
<div class="row speakerListItems" ng-repeat="speakering in item.speakers track by $index">
<div class="col-50">
<p style="float:left">{{speakering.speaker}}</p>
</div>
<div class="col-50">
<p style="float:right">Hello</p>
</div>
</div>
</li>
</ion-scroll>
</ion-content>
</body>
</html>
I would like to assign a dynamic background-color to each list item using the getNumber() function to determine the color based on a generated value. View the Codepen demo here - CODEPEN DEMO