ng-repeat

Creating multi-level lists with ng-repeat

Deadly 提交于 2020-01-01 10:08:49
问题 I am trying to make a multi-level list from an object that contains the nesting data: function linksRarrange($scope) { $scope.links = [ { text: 'Menu Item 1', url: '#', },{ text: 'Menu Item 2', url: '#', submenu: [ { text: 'Sub-menu Item 3', url: '#', },{ text: 'Sub-menu Item 4', url: '#', submenu: [ { text: 'Sub-sub-menu Item 5', url: '#', },{ text: 'Sub-sub-menu Item 6', url: '#', } ] } ] },{ text: 'Menu Item 3', url: '#', } ]; } Why does this outputs only the first 2 level menus and

How to remove initial blank option and select <option> value when using ng-repeat or ng-options?

最后都变了- 提交于 2019-12-30 14:50:08
问题 Angular newbie. Filtering json data returned via dataservice, and filter is done via dropdown. What i would like to do is a combination of things: I would like to remove the initial blank value returned via Angular; I would also like to have it pre-select a value by default that is not included in my data object (in my case, returning all objects, added as a select option via my html); and I would like to have that initial default value displayed when the page is rendered. I can remove the

Assigning ng-model to checkboxes generated by ng-repeat

主宰稳场 提交于 2019-12-29 04:42:11
问题 I have set up a json containing a list of countries with an ID and Country code attached: It looks like this: $scope.countries = [ {"name":"Afghanistan","id":"AFG","country-code":"004"}, {"name":"Åland Islands","id":"ALA","country-code":"248"}, {"name":"Albania","id":"ALB","country-code":"008"}, {"name":"Algeria","id":"DZA","country-code":"012"} ] I then use the ng-repeat directive to create checkbox inputs for every country. <div ng-repeat="country in countries"> <label><input type="checkbox

Adding parameter to ng-click function inside ng-repeat doesn't seem to work

风格不统一 提交于 2019-12-27 10:29:29
问题 I have a simple loop with ng-repeat like this: <li ng-repeat='task in tasks'> <p> {{task.name}} <button ng-click="removeTask({{task.id}})">remove</button> </li> There is a function in the controller $scope.removeTask(taskID) . As far as I know Angular will first render the view and replace interpolated {{task.id}} with a number, and then, on click event, will evaluate ng-click string. In this case ng-click gets totally what is expected, ie: ng-click="removeTask(5)". However... it's not doing

AngularJS function in controller and factory not working when separated

为君一笑 提交于 2019-12-25 18:41:14
问题 angular.module('myFirstApp')// //begin controller .controller('myController',function($scope,$http,personFactory){ //hi im controller i need to call the http service from the factory //begin service //hi im service i dont want to live in controller.js , i want to live in app.js //can we put the service inside a factory which is in app.js file and get called using controller #1 $http.get('iphone.json').success(function(result){ $scope.ObjectArray = result; }).error(function(error){ alert(error

Removing a value from an array and moving them to another Array

丶灬走出姿态 提交于 2019-12-25 08:15:34
问题 I have a dropdown values from $scope.role from there I am able to select and remove the respective value from that dropdown and moving the values to $scope.multiRoles array . Which I am also displaying as tags .Which can be find in AddRole() Now when I click close button in the tag, I am calling removeRoles() , where I am splicing the array which I am selected. But I need to splice them and move them back to $scope.role . Till removing value it works fine , but I am unable to move it back to

Ng-repeat inside ng-repeat

▼魔方 西西 提交于 2019-12-25 06:41:25
问题 <ul ng-repeat="cate in restaurant.categories"><li>{{cate}}</li> <li ng-repeat="menuItem in restaurant.menuItems" ng-show="menuItem.category == cate">{{menuItem.name}}</li></ul> I want one ng-repeat loop inside another and to show the menu only if the menuItem is in the category. I only have items in the first category loop, and empty for all the other categories. Categories and menuItem are 2 different arrays. If the menuItem's category is under the current category it should be added to the

Slow reaction to button click in NgRepeat list of 1000 items

梦想的初衷 提交于 2019-12-24 15:49:41
问题 I have a list of 1000+ items which I display using NgRepeat in Angular 1.3. The list populates with buttons. I have noticed significant delay on the click event int he list once it grows in size. When the list is only 5-10 items the clicks are instant. When the list is 1000 there is about 2-5 second delay before the button clicks are actually processed. Now I cannot tell if this is a browser issue, but I suspect it has to do with too many listeners being used somewhere, causing the browser to

$index, in Table, not sequential… angularjs

时光怂恿深爱的人放手 提交于 2019-12-24 08:18:06
问题 I have a table in HTML. The rows are counted (via use of $index ), and only certain rows are shown (via use of ng-show ). Problem : $index does not return the right count. The table's count should go like "1,2,3...", but it does not. <tbody> <tr ng-repeat="fruit in basket" ng-show="fruit.isJuicy == type"> <td>{{$index + 1}}</td> <td>{{fruit.Name}}</td> </tr> </tbody> Here's the JSFiddle ; don't forget to click on the buttons to see the issue: http://jsfiddle.net/f6HCX/2/ What is causing this

Not able to display correct data in table -AngularJS

不问归期 提交于 2019-12-24 04:32:07
问题 Below is my plunker where I have tried to display the data under each category.But the data are not printing as supposed to .Example:-rom value 12345 should come directly under bread. I'm not sure where I'm doing wrong in my code: $scope.allProducts = []; angular.forEach($scope.data,function(item, index){ angular.forEach(item.products, function(item2, index){ if($scope.allProducts.indexOf(item2.consummable) == -1){ $scope.allProducts.push(item2.consummable); } }) }) Creating a table matrix