ng-repeat

update/refresh angularjs ng-repeat with data from server

北战南征 提交于 2019-12-12 02:23:34
问题 I try to buil a website to like some pictures. I can load the picture, but I want to have a like system with who like the picture. my problem was I have to refresh the page to see who like this picture and increment the count. this my controller : $scope.loadingpics = function (){ $http.get('/api/photos') .success(function(awesomeThings) { console.log(awesomeThings); $scope.firstname = awesomeThings; }) .error(function (err){ $scope.errors.other = err.message; }); }; $scope.upVote = function

Iterate over array which includes objects

戏子无情 提交于 2019-12-12 01:27:56
问题 I am wondering how can I view different objects within an object using ng-repeat? This is the following code that I have so far, to iterate over the $ID of the objects in array: <div ng-repeat="message in messages"> {{message.$id}} </div> This is how my array looks like: http://imgur.com/8quH0iW As you can see, the array structure looks like that: --Item[0]: -----$Id:xxxxx -----Message1(unique ID): -------------:date: "XX-XX-XXXX" -------------:message: "whatever" -------------:sender:

How to count unique results based on a particular properties within ng-options

这一生的挚爱 提交于 2019-12-12 00:34:06
问题 I'm working with AngularJS and trying to create a filter to search properties. I've got a select box like this: <select class="selectBox" multiple="multiple" ng-model="selectedSubArea" ng-options="property.SubArea as (property.SubArea + ' ('+ filtered.length +')') for property in filtered = (properties | unique:'SubArea') | orderBy:'SubArea'"> </select> This is the unique function: myApp.filter('unique', function() { return function(input, key) { var unique = {}; var uniqueList = []; for(var

Angularjs: summarizing data in one loop with ng-repeat

醉酒当歌 提交于 2019-12-11 17:11:48
问题 I'm trying to rationalize ng-repeat to display and summarize data in one loop. Note: DON'T bring solutions which require looping through the data more then one time. Here is my Ctrl $scope.summary = { keren: 0 , r: 0 , sum: 0 , extra: 0 } $scope.gainSummary = function(obj) { var k = $scope.summary; console.log(obj) if (typeof obj == 'object') { k.keren += obj.keren; k.r += obj.r k.sum += obj.sum k.extra += obj.extra } else { return k; } } $scope.board = [ { date: '10/11/2015' , keren: '1026

AngularJS ngRepeat and jQuery - DOM rebuilding issues

不问归期 提交于 2019-12-11 14:47:34
问题 I am very well aware how mixing angularjs and jquery is NOT a good idea. However, I need a custom carousel, which could slide through TEXT ONLY. All the existing carousel animations for angularjs depend heavily on image being part of the content, whereas I have no images. So I found a very good jquery library for such a thing, called "slick". It works well with angularjs, but when I dynamically ADD new values to an existing array, the whole thing breaks apart. How could I change this part of

Binding ng-repeat and ng-model in controller

社会主义新天地 提交于 2019-12-11 13:54:33
问题 This is my first post on here so bear with me, I'm fairly new to AngularJS as well. I'm trying to build a form with ng-repeat and having trouble wrapping my head around the angular stuff. JS in controller: $scope.myCurrentAssets = { cash_equiv: {name: 'Cash & Equivalents', value: 0, tbi: 41}, invest: {name: 'Short Term Investments', value: 0, tbi: 42}, notes_rec: {name: 'Notes Receivable', value: 0, tbi: 43}, account_rec: {name: 'Accounts Receivable', value: 0, tbi: 44}, inventory: {name:

angular ng-repeat with directive

妖精的绣舞 提交于 2019-12-11 12:43:44
问题 i'm new to angular and have the following issue where i need assistence. I'm using angular charts directives http://jtblin.github.io/angular-chart.js/ to build a chart board. I got the follwoing scenario: I have a directive a view and anenter code here associated controller. Inside the controller there should be an array charts[] which holds objects. these objects should be two-way binded with the chart directive. What is the appropriate way to do so? I will bild my charts dynamically without

Angular reading data from a json file based on another json file

北战南征 提交于 2019-12-11 12:32:15
问题 I'm new to angular and have run into a scenario where I don't know the best way to setup this code. I have 2 JSON files: images.json { "imageName": "example.jpg", "imageTags": ["fun","work","utility"] "productID": ["item1","item3"] } products.json { "productID": "item1", "productName": "Staple Gun", "productURL": "Staple-Gun.htm" } I don't have any code yet, I'm really trying to make sure I build this properly first. My goal is to pull images based on tags, so I put a filter on the first ng

angular ng-options with preselected value by object id

佐手、 提交于 2019-12-11 11:12:12
问题 Is there a way the following select can have a pre-selected club ? <select ng-model="c.pilot.clubIdx" ng-options="club.idx as club.name for club in c.clubs track by club.idx"> c.pilot.clubIdx = 2 c.clubs = { {idx: 1, name: "club1"}, {idx: 2, name: "club2"} } The select-menu should show "club2". Since the clubs are stored in a db and can be altered, I like to keep them only as references on the pilots . SOLVED: removing track by solves the problem. 回答1: in the controller set the ng-model of

Can't get the filtered items from my filtered list inside a modal

与世无争的帅哥 提交于 2019-12-11 08:17:44
问题 I have a page where I can open a modal window when selecting a certain "instruction" When that modal window is loaded, I have inside of it a text input for searching, an ordered list to list all of the "instructions" (except the one I selected), a dropdown list to select the amount of instructions I want to see per page, 2 buttons for next and previous page as well as text showing the current page and how many page there is. This is what it looks like (the Manual dropdown list does nothing