i want to show this accordion based on category that i select from selectBox,
for now it only show all data, but i want to give some filter.
Here is my code and my database.
anyone know how to do it without change any database or using angularUI accordion?
<div class="cs_member_info">
<select class="cs_member_select">
<option value="A">Type 1</option>
<option value="B">Type 2</option>
<option value="C">Type 3</option>
</select>
</div>
<div class="cs_body" ng-repeat="cs in csList">
<div class="cs_acc_div">
<button class="cs_accordion" ng-class="{'active': isClicked, 'off' : !isClicked}" ng-click="isClicked = !isClicked">
<p class="noti_title">
{{cs.faq.title}}
</p>
</button>
<div class="panel" ng-show="isClicked">
<p class="panel_inside">
{{cs.faq.contents}}
</p>
</div>
</div>
</div>
"_id":"59111a018479e30d387be584",
"lang":1,
"type":"FAQ",
"created_at":"2017-05-09T01:23:13.324Z",
"category":{
"code":1,
"name":"Member information"
},
"faq":{
"title":"Login with SNS ID",
"contents":"Login with SNS ID"
}
Check this as a reference. default angular filter
https://plnkr.co/edit/PpWo28ZO6QNiKEo1K5K7?p=preview
Here it is a table. use accordion to repeat and then filter it
Check this documentation https://docs.angularjs.org/api/ng/filter/filter
<label>Name only
<select ng-model="search.name">
<option value="John">John</option>
<option value="Mary">Mary</option>
<option value="Mary">Mary</option>
</select>
</label>
<br>
<table id="searchObjResults">
<tr>
<th>Name</th>
<th>Phone</th>
</tr>
<tr ng-repeat="friendObj in friends | filter:search:strict">
<td>{{friendObj.name}}</td>
<td>{{friendObj.phone}}</td>
</tr>
</table>
Related
<select class="form-control" id="selectrequest" ng-model="selectedrequest">
<option value="pending" > Pending </option>
<option value="approved"> Approved </option>
<option value="rejected"> Rejected </option>
</select>
<tr ng-repeat="mymodel in vm.modelname | filter:selectedrequest">
<td>{{mymodel.name}}</td>
<td>{{mymodel.triggername}}</td>
<td>{{mymodel.status}}<td>
</tr>
vm.modelname=[{
name:'Peter',
triggername:'Peter1',
status:pending
},{
name:'Jack',
trigger name:'Jack Hein',
status:approved
}]
Prob stint: by default pending status is selected and corresponding data is populated. let me know if further clarification is needed.
Declare a variable using $scope as:
$scope.selected_request = "Pending";
With this by default your intended data is selected.
Please made changes in your select tag like below. It will make "approved" selected by default and also populate your table according to selection.
Hope it will help.
<body>
<h2>AngularJS Sample Application</h2>
<div ng-app="mainApp" ng-controller="studentController">
<select class="form-control" id="selectrequest" ng-init="selected_request='approved';selected_requested()" ng-model="selected_request" ng-change="selected_requested()">
<option value="Pending"> Pending </option>
<option value="approved" > Approved </option>
<option value="rejected"> Rejected </option>
</select>
<div ng-repeat="temp in model | filter:(!!selected_request || undefined) && {status: selected_request} ">
<span ng-bind="temp.name">
</span>
</div>
<br/> Items in filtered Array
<br/>
<div ng-repeat="temp in filteredArray">
<span ng-bind="temp.name">
</span>
</div>
</div>
</body>
I have a page with on it a selectList
<div>
<fieldset class="fieldset" style="width:500px">
<legend>#CeMagResources.SelectArticle</legend>
<div>
<select data-ng-model="vm.newBon.CurrentArtikel" data-ng-options="artikel.omschrijving for artikel in vm.artikels track by artikel.id" style="width:100%"> </select>
</div>
<div data-ng-if="!vm.isNewArticleHidden" style="width:100%">
<div ng-include src="'#Url.Action("AddArticle", "Artikel")'" ></div>
</div>
</fieldset>
</div>
This page includes this
<div>
<fieldset class="fieldset">
<legend>#CeMagResources.ArticleAdd <img style="vertical-align: central" alt="new" data-ng-click="vm.addArticle()" class="icon-new" src="#Links.Content.icons.add_png"></legend>
<table>
<tr>
<td>
<label class="ui-form ui-form-label">#CeMagResources.ArticleName:</label>
</td>
<td>
<input type="text" style="width: 150px" data-ng-model="vm.newBon.CurrentArtikel.Code" capitalize>
</td>
</tr>
<tr>
<td>
<label class="ui-form ui-form-label">#CeMagResources.ArticleDescription:</label>
</td>
<td>
<input type="text" style="width: 150px" data-ng-model="vm.newBon.CurrentArtikel.Omschrijving" />
</td>
</tr>
</table>
</fieldset>
</div>
In my .ts-file I have a functions where I add the article.
Here i send the article to the server, where it is added. So far so good.
addArticle = () => {
this.bonSrv.addArticle(this.newBon.CurrentArtikel).success(this.setNewArticle);
}
When i return from the angular-promise, i come into this function.
The article returned is the same as this.newBon.CurrentArtikel, only it has also an ID, what i need in the selectList.
setNewArticle = (artikel: IArtikel) => {
this.artikels.push(artikel);
this.newBon.CurrentArtikel = artikel;
this.hideNewArticle();
}
I already read here that ng-include creates an child-scope and many solutions on the web suggest that i must use an
object to bind it to. This i already do
Also other suggest that i must use ng-options. This i also do.
When i debug in chrome, i see that the new article is pushed to the list and set as this.newBon.CurrentArticle()
Has anyone a idea why i get an undefined-option in my selectlist?
<select data-ng-model="vm.newBon.CurrentArtikel" data-ng-options="artikel.omschrijving for artikel in vm.artikels track by artikel.id" style="width:100%" class="ng-pristine ng-valid ng-touched">
<option value="4" label="A2-Papier">A2-Papier</option>
<option value="3" label="A3-papier">A3-papier</option>
...
<option value="41" label="Zonnebril">Zonnebril</option>
<option value="undefined" label="undefined" selected="selected"></option>
</select>
I want to filter my table using select value. In my code below, using input type=text... filter works just fine. But i don't know how to filter using select value.
<div class="columns large-2-5">
<select name="categorySelector"
class="selectbox"
ng-model="search"
ng-options="category.name for category in categories">
<option value="">Select Category</option>
</select>
</div>
<div class="row">
<input type="text" ng-model="search.name">
<table class="grid">
<tbody ng-repeat="image in imageList | filter: { category: search.name }">
<tr photolistsetting-Directive
title="{{ image.name }}"
ref="{{ image.url }}"
category="{{ image.category }}">
</tr>
</tbody>
</table>
</div>
select list is made of objects. Maybe i can't access an object property ?
Thank you.
Use this:
<select name="categorySelector"
class="selectbox"
ng-model="search.name"
ng-options="category.name for category in categories">
<option value="">Select Category</option>
</select>
Edit: Sorry I pointed out incorrect earlier.
Can you post "categories" and "imageList" array here?
I am trying to make the same functionality with the google form, which is when user choose different question type, it will show different style for data input, such as text, paragraph text, multi-choice.
Here is the link of my code:
My problem is when I choose one of the question type, it does not work, goes back to the last state.
I don't know why.
Here is part of my code:
<tr>
<th>
<label class="question_label">Question Type</label>
</th>
<td>
<select class="question_dropdown" ng-model="question.type">
<option value= "text">Text</option>
<option value= "paragraph">Paragraph Text</option>
<option value= "radio">Multiple Choice</option>
<option value= "checkbox">Checkboxes</option>
<option value= "list">Choose from a list</option>
</select>
</td>
</tr>
</tbody>
</table>
<div class="question_typeContainer" ng-switch="question.type">
<div class="question_typeText" ng-switch-when="text">
<input class="question_textfield disabled" value="Their answer" disabled>
</div>
<div class="question_typeText" ng-switch-when="paragraph">
<input class="question_textfield disabled" value="Their answer" disabled>
</div>
</div>
It seems to work fine if you use ng-show instead of ng-switch-when. Try this out.
<div class="question_typeContainer">
<div class="question_typeText" ng-show="question.type == 'text'">
<input class="question_textfield disabled" value="Their answer" disabled>
</div>
<div class="question_typeText" ng-show="question.type == 'paragraph'">
<input class="question_textfield disabled" value="Their answer" disabled>
</div>
</div>
I am trying to display the data in the screen shot only when "Arts & Culture" option is selected from drop down box whose default value is " Choose Category". The code in my html is :
<div class="well">
<h3>All Adventures</h3>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<table>
<tr><td>
<select name="" id="" ng-model="category" ng-options="c for c in categories">
<option value="">-- Choose Category --</option>
</select>
</td>
<td><input type="text" value="Enter Current Location" /></td>
</tr>
<tr>
<td> </td>
<td><select name="" id="" ng-model="tMode" ng-options="tM for tM in tModes">
<option value="">-- Choose Transportation Mode --</option>
</select></td>
</tr>
</table>
<br/>
</div>
<ul class="unstyled">
<li ng-repeat="art in arts">
<div class="well">
<h4>{{art.name}}</h4>
<h5><em>{{art.formatted_address}}</em></h5>
<p>{{art.formatted_phone_number}}</p>
<p>{{art.vicinity}}</p>
<p>{{art.types}}</p>
</div>
</li>
</ul>
What changes in code must i make to make this work. I have been trying many examples on the web, but no luck so far.
<li ng-repeat="art in arts" ng-show="category == 'Arts & Culture'">