Note that there are some explanatory texts on larger screens.

plurals
  1. POng-repeat and select box filtering
    primarykey
    data
    text
    <p>I have an article list and categories. All I need is updating the article list based on selected category.</p> <p>I can populate the list with all the articles, I've no problem on that part. But I could not populate the category select box and I could not bind a function to category list's on change event.</p> <p>Here is the code:</p> <pre><code>&lt;script&gt; function contrArticles($scope, $http) { $scope.articles = []; $scope.categories = []; $http({ method: 'GET', url: 'dbOps.aspx?act=articleList' }). success(function (data, status, headers, config) { $scope.articles = data.Table; }). error(function (data, status, headers, config) { console.log('http error'); } ); $http({ method: 'GET', url: 'dbOps.aspx?act=categoryList' }). success(function (data, status, headers, config) { $scope.categories = data.Table; }). error(function (data, status, headers, config) { console.log('http error'); } ); $scope.selectCategory = function () { $http({ method: 'GET', url: 'dbOps.aspx?act=categoryList&amp;catID=' + $scope.category}). success(function (data, status, headers, config) { $scope.categories= data.Table; }). error(function (data, status, headers, config) { console.log('http error'); } ); } } &lt;/script&gt; &lt;div ng-controller="contrArticles"&gt; &lt;ul class="article_list"&gt; &lt;li ng-repeat="article in articles | filter:search"&gt; &lt;a href="#" title="article title here"&gt; &lt;span class="date"&gt; &lt;span class="month"&gt;{{ article.dt_month }}&lt;/span&gt; &lt;span class="day"&gt;{{ article.dt_day }}&lt;/span&gt; &lt;span class="year"&gt;{{ article.dt_year }}&lt;/span&gt; &lt;/span&gt; &lt;img ng-src="images/news/{{ article.id }}.jpg" alt="{{ article.title }}" class="thumb" /&gt; &lt;div class="summary"&gt; &lt;span class="article_title"&gt;{{ article.title }}&lt;/span&gt; &lt;span class="short"&gt;{{ article.content }}...&lt;/span&gt; &lt;/div&gt; &lt;/a&gt; &lt;/li&gt; &lt;li ng-show="(articles | filter:search).length==0"&gt;No article found&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;select class="combobox" ng-change="selectCategory ()" ng-model="category"&gt; &lt;option value=""&gt;Show all&lt;/option&gt; &lt;option ng:repeat="s in sports" value="{{ s.id }}"&gt;{{ s.tag }}&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Thanks.</p>
    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.
 

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