last day (14 days later) » 

11:34 AM
0
Q: Angular JS - repeat image tag for specified number in json (value is availabe in json)

FlashyFuddyFuddyI want to repeat my image tag for specified number of times (value is available in json). <table class="table table-bordered"> <tbody> <tr ng-repeat="user in users[0].tvseries | filter: searchText | filter: genre.config | orderBy:predicate"> <td><img ng-src="{{user.thumbnail}}" ...

 
It is working.. jsfiddle.net/cHQLH/89 just change myNumber with a real number :)
 
Hi Lorenzo, I want that number to be coming from my json. The variable ($scope.products_page) mentioned above has the array of ratings from my json. But seems my image tag is not getting repeated.
 
Then what is the num parameter in getNumber function.. It is never used..
 
Hi Lorenzo, sorry that was my mistake. It should have been getNumber(user.rating) where I said, {{user.rating}} has the exact number of times the image tag needs to be repeated. I have also modified the controller to return an array of {{user.rating}}. But still I dont get the image repeated :( And the fiddle I have posted, is just a reference I got while browsing for a solution.
 
If {{user.rating}} has the number of items then just do ng-repeat="rate in user.rating"
 
11:34 AM
I have modified my html to -> <img ng-repeat="rate in user.rating" src="img/star.png" width="15" height="15" /> Still I could see only one image. Its not repeating. :(
 
if you do alert($user.rating) in your controller what is the result ?
 
Hi Lorenzo
 
Hi
So what is the result of $user.rating
 
as I told before, I use {{user.rating}} which is fetched from json
I have not declared it as a variable in my controller
so its throwing an error
 
Show me your controller please
 
11:40 AM
Gimme a min
I face some connection issue
 
Ok, just post your controller when you can
 
Definitely
This is my controller
var myModule = angular.module('myModule', []);
myModule.controller('myController', function ($scope, userRepository) {
userRepository.getAllUsers().success(function (users) {
$scope.users = users;
});
$scope.genre = {};
$scope.genre.configs = [{
'name': 'All',
'value': '0'
}, {
'name': 'Action',
'value': 'action'
}, {
'name': 'Animation',
'value': 'animation'
}, {
'name': 'Comedy',
'value': 'comedy'
}, {
'name': 'Fantasy',
'value': 'fantasy'
}, {
'name': 'Drama',
'value': 'drama'
}, {
'name': 'Mystery',
 
11:59 AM
if I have the key-value pair as rating:7, then as we see in IMDB site, I need 7 stars to be repeated. This is the concept i was working on
 
Ok so it should work.. Sorry cannot find something wrong in your code.
 

last day (14 days later) »