angularjs-ng-repeat

How do I dynamically build an ng-include src?

半城伤御伤魂 提交于 2019-12-03 14:40:36
问题 I have the following code: <div ng-repeat="module in modules" id="{{module.Id}}"> <ng-include ng-init="bootstrapModule(module.Id)" src=""></ng-include> </div> I want to be able to build a string in src like so: /modules/{{module.Name}}/{{module.Name}}.tpl.html But I keep hitting roadblocks. I've tried to use a call back function to build it, $scope.constructTemplateUrl = function(id) { return '/modules/' + id + '/' + id + '.tpl.html'; } But this gets called over & over & over and it doesn't

Angular JS: ng-repeat with dynamic ng-model

会有一股神秘感。 提交于 2019-12-03 14:18:22
I have this working piece of code that is repeated multiple times, hence would be great for a ng-repeat loop. For example, two instances of my code are the following. <div> <input type="text" ng-model="searchParamaters.userName" placeholder="User Name"/> <i class="fa fa-times" ng-click="resetSearchField(filterParamDisplay[0].param)" ng-show="showParam(filterParamDisplay[0].param)"></i> </div> <div> <input type="text" ng-model="searchParamaters.userEmail" placeholder="User Email"/> <i class="fa fa-times" ng-click="resetSearchField(filterParamDisplay[1].param)" ng-show="showParam

How to load more elements with AngularJS?

狂风中的少年 提交于 2019-12-03 13:54:14
问题 for a while I am trying to find how to make a load more(elements from an array) button,using Angular. I have 9 elements in array, I use ng-repeat to loop them, and limitTo:3 to output first 3. Questions: 1: is possible to make a load more button using only angular?(load more button is at bottom in example) 2: if not, how to make this work using jQuery? http://plnkr.co/edit/1gHB9zr0lbEBwlCYJ3jQ Thanks! 回答1: You don't need to think of jQuery, as you could solve this problem easily by using

AngularJS: traversing nested arrays

社会主义新天地 提交于 2019-12-03 13:40:46
问题 I am working with a nested array with the structure... $scope.items = [{attr1: val1, attr2: val2, items: [{ attr1: val1, attr2: val2, items: [{ ... }, ...] }, ...] }, ...]; which goes into an ng-repeat with ng-include like this <div ng-repeat="item in items" ng-include="'/path/to/template.tpl.html'"></div> and template.tpl.html is <div>{{item.attr1}}<\div> <div>{{item.attr2}}<\div> <div ng-click="fnAddNewItemBelow(item, $parent)"><\div> <div ng-repeat="item in item.items" ng-include="'/path

Angular pagination not updating when bound list changes due to filtering on an input text box

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 13:33:16
问题 Here's the scenario: I am using an ASP.NET MVC site with Angular JS and Boostrap UI. I have a dynamic ul list populated by data fed through a controller call to AngularJS, filtering on that list through an input search box. The list is also controlled through pagination (UI Bootstrap control) that I've setup to show 10 results per page for the list of 100 or so items. This list is filtered as the user types in the search box, however I would like the pagination to update as well so consider

ng-repeat with ng-include not working

那年仲夏 提交于 2019-12-03 12:40:28
I am trying to use an ng-repeat that includes an ng-include . The problem is that the first element in the ng-repeat is just the ng-include template with none of the data from the ng-repeat filled in. Is there a way I can somehow bind the template from the ng-include so it works on the first ng-repeat ? <div ng-repeat="item in items"> <div ng-include src="'views/template.html'"></div> </div> For example, if my ng-repeat contains 10 items, then the first item that is rendered will just be the empty template. Items 2-10 WILL be rendered as they should be. What am I doing wrong? First make sure

Animating ng-move in AngularJS ngRepeat is animating the wrong items

故事扮演 提交于 2019-12-03 12:01:06
I'm a little flummoxed when it comes to animating ng-move in an ng-repeat. If I move an array item from 3 to 7 for instance, items 4-7 get shifted up and they animate. However the actual item I moved from 3 and placed in position 7, does not. Here's a plunkr demonstrating my issue. http://plnkr.co/edit/4yRkLWbsU57YxrYOrWUQ?p=preview Moving item 7 to 3, however, works as I expect, animating the single moved item, and not the items that have been pushed down. This is not very useful for showing a user what moved. How should someone properly animate an ng-move? antoine @tasseKat has an excellent

How to show images in img tag inside an ng-repeat while using Angular JS?

时光总嘲笑我的痴心妄想 提交于 2019-12-03 11:56:31
问题 My problem: I want to display a list of images, stored localy, using ng-repeat directive, but the images re not being displayed. AngularJS version: 1.2.22 The code: Directory Structure: myapp/ |--- common/ | |--- images/ | |--- image.png | |--- subapp1/ | |--- index.html | |--- subapp1.js | | | |--- controllers/ | | |--- SubApp1Controller.js | | | |--- views/ | | |--- imageListView.html index.html <!DOCTYPE html> <html lang="en" data-ng-app="SubApp1"> <head> <meta charset="utf-8" /> </head>

Angular ng-if inside option element and ng-repeat not working

天大地大妈咪最大 提交于 2019-12-03 11:51:13
I have select element which should list available currencies. Default currency should have prefix "Default" before its name. For some reason, that prefix is showing for all currencies in the list. Test HTML: <div ng-app="testApp"> <div ng-controller="MainCtrl"> <select> <option ng-repeat="rate in rates track by $index"> <span ng-if="rate.is_default">Default</span> <span>{{rate.name}}</span> </option> </select> </div> </div> TEST JS: var app = angular.module("testApp", []); app.controller("MainCtrl", function($scope){ $scope.rates = [ { 'name': 'dolar', 'is_default': true}, { 'name': 'pound',

“Duplicates in a repeater are not allowed” on ng-repeat

浪尽此生 提交于 2019-12-03 11:00:16
问题 I've got the following json data returned from a service request: { "entries": [{ "id": 2081, "name": "BM", "niceName": "bodmas" }] }, { "id": 8029, "name": "Mas", "niceName": "Masm" }] }], "count": 2 } And I am trying the following code in html to loop through this data: <option ng-repeat="entry in entries" value="{{entry.name}}">{{entry.name}}</option> I get the following error when I run the code: Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression