Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a little open ended and lots of different ways to tackle. If the list of markets and corresponding detail is minimal, i would pull it all in one initial json request and have my model likes so:</p> <pre><code> var markets = [{"name":"market1", "detail": {"description":"blah blah"} }] </code></pre> <p>html:</p> <pre><code>&lt;div ng-controller="MarketCtrl"&gt; Please select a market: &lt;span ng-repeat="market in markets" ng-click="setMarket(market)" ng-class="getClass(market.name)"&gt;{{market.name}}&lt;/span&gt; You have selected {{curMarket.name}}as the market. &lt;div&gt; {{curMarket.detail.description}} &lt;/div&gt; &lt;/div&gt; </code></pre> <p>controller:</p> <pre><code>MarketCtrl= function($scope){ $scope.curMarket={}; $scope.getClass = function(name){ return name.replace(" ", "_") } $scope.setMarket(market){ $scope.curMarket=market; } } </code></pre> <p>If you want to call the data cause its too much:</p> <pre><code>var markets = [{"name":"market1", "id":1 }, {"name":"market2", "id":2}] </code></pre> <p>html:</p> <pre><code>&lt;div ng-controller="MarketCtrl"&gt; Please select a market: &lt;span ng-repeat="market in markets" ng-click="getMarket(market)" ng-class="getClass(market.name)"&gt;{{market.name}}&lt;/span&gt; You have selected {{curMarket.name}}as the market. &lt;div&gt; {{curMarket.detail.description}} &lt;/div&gt; &lt;/div&gt; </code></pre> <p>controller:</p> <pre><code>MarketCtrl= function($scope, $http){ $scope.curMarket={}; $scope.getClass = function(name){ return name.replace(" ", "_") } $scope.getMarket(market){ var url=''; $http.get(url).success(function(data){ $scope.curMarket=data; }); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload