angularjs-ng-repeat

Angular HTML Select option disable and enable

你说的曾经没有我的故事 提交于 2019-12-05 12:49:09
问题 I have a html select option <select> <option ng-repeat="field in filter.fields" value="{{field.id}}">{{field.name}}</option> </select> which I am iterating from ng-repeat , I want to disable option on basis of a filed selectable like <select> <option ng-repeat="field in filter.fields" {field.selectable==true?enable:disable} value="{{field.id}}">{{field.name}}</option> </select> How can I achieve this with angular? 回答1: Assuming you have a structure like this: $scope.filter = { fields: [ {id:

Comparing objects between 2 nested arrays in Angularjs and display respective matching data

自作多情 提交于 2019-12-05 12:05:06
I'm having two arrays : first one is empdata holding empid and events attended by that employee, then second array is holding event details. I need to compare empid from array with user input and display particular event details attended by respective employee using collapsible jQuery . Find total price also. $scope.empdata=[]; $scope.data = []; //first array data $scope.empdata.push({ empid:'empid_1', events:[{ event:'First Event' }, { event:'Second Event' } ]}) $scope.empdata.push({ empid:'empid_2', events:[{ event:'First Event' }, { event:'Second Event' }, { event:'Third Event' }] }) /

Dynamic filter within ng-repeat in AngularJS

╄→尐↘猪︶ㄣ 提交于 2019-12-05 10:30:19
For my AngularJS app I have an ng-repeat in an ng-repeat like so: Html: <div ng-app="myApp"> <div ng-controller="myController"> <h2>working filter</h2> <div ng-repeat="category in categories"> <h3>{{category}}</h3> <div ng-repeat="item in items | filter:{price.red: 0} ">{{item.name}}</div> </div> <h2>broken filter</h2> <div ng-repeat="category in categories"> <h3>{{category}}</h3> <!-- price[category] should be red, blue, yellow, depending on the category in the ng-repeat --> <!-- price[category] should be bigger then 0 (or not zero, negative values will not occur) --> <div ng-repeat="item in

Displaying sub-array in ng-repeat

試著忘記壹切 提交于 2019-12-05 10:16:23
In my Angular app I have the following <select> element that is populated like so: HTML <select name="device[ [[$index]] ]" ng-model="selectedModel" ng-change="loadModelImage(selectedModel)"> <option value="">Model</option> <option ng-repeat="model in manufacturerModels" value="[[model.id]]">[[model.model]]</option> </select> JS $scope.manufacturerModels = $filter('filter')($scope.models, {manufacturer_id: manufacturerId}); The above AngularJS snippet will return a JSON response of handset models stored in the API. (I'd post an example here but each object is quite lengthy). Anyway, inside

Nested comments in AngularJS with ng-repeat

一个人想着一个人 提交于 2019-12-05 09:59:05
I've created a directive for displaying nested comments in AngularJS. The main point of it was to have infinite comments when returned JSON from API would look something like this: [ { 'id': 66, 'text': 'This is the first comment.', 'creator': { 'id': 52, 'display_name': 'Ben' }, 'respondsto': null, 'created_at': '2014-08-14T13:19:59.751Z', 'responses': [ { 'id': 71, 'text': 'This is a response to the first comment.', 'creator': { 'id': 14, 'display_name': 'Daniel', }, 'respondsto': 66, 'created_at': '2014-08-14T13:27:13.915Z', 'responses': [ { 'id': 87, 'text': 'This is a response to the

angularJS filter expression in ng-repeat

末鹿安然 提交于 2019-12-05 09:06:41
I would like to know what is the most elegant and simple way to implement this. I need to add a filter expression for a ng-repeat that would filter 2 conditions from one property. In this example http://plnkr.co/edit/OMQxXvSjtuudMRGE4eZ8?p=preview If you enter A, it would display checkbox for A, enter B - display checkbox for B. But I want to display the specified checkboxes plus anything with empty condition. There is no condition for C, so: if you enter A, I want to display both A and C checkboxes, enter B, I want to display both B and C checkboxes. I would create custom filter like: app

form validation angularjs without submit button

若如初见. 提交于 2019-12-05 08:08:51
I want validation of the form which do not have the submit button. <div ng-controller="UserCreationCtrl"> <form novalidate="novalidate" class="form-horizontal"> <div class="control-group"> <label class="control-label" for="inputUserLogin">User Login:</label> <div class="controls"> <input type="email" id="inputUserLogin" ng-model="user.userLogin" placeholder="User Login" required /> </div> </div> <div class="control-group"> <label class="control-label" for="inputFirstName">First name:</label> <div class="controls"> <input type="text" id="inputFirstName" ng-model="user.firstName" placeholder=

how to append items to the same row or line with ng-repeat

橙三吉。 提交于 2019-12-05 07:55:35
I'd like to append items to the same row with ng-repeat, but it seems to add the items on a new line. In the following example I'd like them to be on the same row like: "John who is 25 years old. Jessie who is 30 years old. Johanna who is 28 years old." The result is instead: John who is 25 years old. Jessie who is 30 years old. Johanna who is 28 years old. How can I accomplish that? <div ng-init="friends = [ {name:'John', age:25, gender:'boy'}, {name:'Jessie', age:30, gender:'girl'}, {name:'Johanna', age:28, gender:'girl'} ]"> <div ng-repeat="friend in friends"> {{friend.name}} who is {

AngularJS multiple forms with ng-repeat validation

筅森魡賤 提交于 2019-12-05 07:50:51
I am using ng-form as a parent form and child mg-forms for validation with ng-repeat. <div ng-form="form"> <div ng-repeat="field in fields"> <div ng-form="subform"><input...></div> </div> </div> And validating like this: if ($scope.form.subform.$invalid && !$scope.form.subform.$error.required) { // Do something... } (this is very simplified example, I have more different subforms for different input types and with different names, e.g. input[text] is named as a TextForm, input[numeric] is NumericForm etc.) Everything works as expected if there is only on field. But if ng-repeat generates

AngularJS : custom iterations/data transformations and grouping… when simple ng-repeat just won't cut it

。_饼干妹妹 提交于 2019-12-05 05:42:30
问题 Still this problem Angular.js more complex conditional loops but I felt that the answer to the question as it was asked was right so I accepted it. So let me elaborate more than I did in the original question. I'm trying to get this <h3>11.4.2013</h3> <ul> <li>oofrab | 4 | 11.4.2013 14:55 <button>remove</button></li> <li>raboof | 3 | 11.4.2013 13:35 <button>remove</button></li> </ul> <h3>10.4.2013</h3> <ul> <li>barfoo | 2 | 10.4.2013 18:10 <button>remove</button></li> <li>foobar | 1 | 10.4