Learn the process of generating dynamic rows in HTML

Currently, I'm working on a website where I am incorporating the Flipkart API to display a list of products. However, the products are not appearing in the well-formatted view that I had designed. Specifically, I want only 4 products to show per row but I am struggling to achieve this. Any guidance would be greatly appreciated.

<div class="container-fluid">   
    <div class="row">
        <div class="column" ng-repeat="data in flipkart">
            <div class="cards card1">
                <a href="" ng-click="userSearchDetails(data.productBaseInfoV1.title)">
                <img src="{{data.productBaseInfoV1.imageUrls.200x200}}" class="img-responsive" style="padding-top: 3px;">
                <strong> <p>Rs {{data.productBaseInfoV1.flipkartSpecialPrice.amount}} </p></strong> </a>
                <h6><strong>{{data.productBaseInfoV1.title}}</strong></h6>
            </div>
        </div>
    </div>
</div>

CSS

<style>
div {
    margin: 0px;
}
.body-class {
    background-color:#FAFAFA;
}
.row {
    content: "";
    display: table;
    overflow:hidden;
    clear: both; 
    margin-left:  45px;
}
.column {
    float: left;
    width: 20%;
    max-height: 50%;
    margin:10px;
    padding-right: 15px;
}

h6 {
    padding:3px;
    overflow: hidden;
}
</style>

Answer №1

If you want to display only 4 cards per line, you can utilize the built-in AngularJS 1.x variable $index within an iteration using ng-repeat.

To achieve this layout, you can implement the following code snippet:

<div class="container-fluid">   
    <div class="row">
        <div class="column" ng-repeat="item in products">
            <div class="card">
                <p>Product {{ $index + 1 }}</p>
            </div>
            <br ng-if="($index+1)%4 === 0" />
        </div>
    </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Javascript document refuses to load

I am currently working on a website with the main file named index.html: <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Title</title> </head> ...

The @Input() property within an Angular component is producing an empty array as its result

I have a calendar component that has a data property marked as @Input(): import { Component, OnInit, Input, OnChanges, SimpleChanges } from '@angular/core'; @Component({ selector: 'app-calendar', templateUrl: './calendar.comp ...

ASP.NET DIV is experiencing issues with Jquery functionality, causing it to flicker and remain fixed in place

As a beginner in JQuery, I am facing an issue with my code in asp.net. Whenever I click on linkbuttons, the behavior is not as expected. The div flickers and does not change its direction. My goal is to move the DIV left or right by 200px, but no matter wh ...

Getting the chosen option from a dropdown list mapped in ReactJS

I am working on a dropdown select option that is linked to the data of an array object called 'template_titles'. Currently, the value in the dropdown corresponds to the title in the object. My goal is to be able to extract and use the selected va ...

Iterate through the complex array of nested objects and modify the values according to specified conditions

I am currently iterating through an array of objects and then delving into a deeply nested array of objects to search for a specific ID. Once the ID is found, I need to update the status to a particular value and return the entire updated array. Issue: Th ...

Utilizing Services in Angular 2

I am new to learning angular2 and encountering an issue with calling a service. The service call is successful, but I am unsure how to handle the data. In Angular1, we would handle it like this: DemoService.getExchangeDataConnection().then(function(respon ...

Exploring the Best Approach to Test RxJS Subject with Jasmine in Angular

I am very new to writing Jasmine unit test cases and I have a scenario that may be simple, but I am unsure of how to cover the test case for ngInit in the following class. Can anyone provide assistance? export class Component1 implements OnInit { deta ...

Angular: Enable function to await Observable completion before returning result

I require assistance with the user function below: getUser(uuid: string): Observable<WowUserDataModel> { let user: WowUserDataModel = { login: null, userUuid: uuid, firstName: null, lastName: null, displayName: nul ...

Determining the pageY value of a div element with overflow-y styling

Currently, I have implemented a script that tracks the mouse's position upon hover. My goal is to integrate this script within a div that has overflow-y: scroll The script currently utilizes pageY which identifies the position relative to the windo ...

Retrieve information from a variety of selected checkboxes

Is there a way to retrieve the values of check boxes that are generated dynamically? @ $db = mysql_connect("abc", "abc", ""); mysql_select_db("abc"); $strSQL = "SELECT * FROM student"; ...

InvalidTypeException: The properties accessed are undefined

Working with Angular 12 and encountering an error when trying to invoke a method within another method. Here is a simplified representation of my situation (in TypeScript, specifically for Angular: export class SomeClass { testvariable on ...

Steps for creating a table with a filter similar to the one shown in the image below

https://i.sstatic.net/zR2UU.png I am unsure how to create two sub-blocks within the Business A Chaud column and Potential Business Column. Thank you! I managed to create a table with input, but I'm struggling to replicate the PUSH & CtoC Column for ...

Dynamic Angular Menu

Is there a cleaner, more dynamic way to implement a mat menu with individual click values and disable properties for each button? I want to avoid repeating code like in the example below. Looking for a more dynamic solution. #code <mat-menu #createDeal ...

ngIf is not refreshing my template

Within my Angular2 application, I have a Component that takes an array as input and utilizes a service to retrieve the Latitude and Longitude for each entry in the array. This involves making multiple asynchronous calls to the service using Promises. expo ...

Whenever npm or ng-packagr are updated, the publishing process may attempt to use an incorrect package name or version

Following the transition to [email protected], [email protected], and Angular@13, I am encountering difficulties while attempting to publish a package generated by ng-packager to the npm repository. This is the content of the package.json file: ...

Having trouble loading the linked CSS file in the Jade template

My directory structure is organized as follows: --votingApp app.js node_modules public css mystyle.css views test.jade mixins.jade In the file mixins.jade, I have created some general purpose blocks like 'bo ...

Need help positioning this HTML iframe on my webpage?

Can anyone help me figure out how to position this HTML i-frame in a specific place on my webpage? <div style="overflow: hidden; width: 333px; height: 156px; position src="h: relative;" id="i_div"><iframe name="i_frame"http://url.com/click.php?a ...

Utilizing Angular 2 for Integration of Google Calendar API

I recently attempted to integrate the Google Calendar API with Angular 2 in order to display upcoming events on a web application I am developing. Following the Google Calendar JavaScript quick-start tutorial, I successfully managed to set up the API, inse ...

Creating a mobile-friendly layout with 3 columns: Tips and tricks

I attempted to solve the issue independently but didn't have much success. My goal is to create a proper version for mobile users using bootstrap, however, it currently looks terrible on mobile devices. I suspect the problem lies with the div classes ...

Adding a stylish underline to text using HTML and CSS

Looking for some assistance with my Html and CSS website project. I am currently facing a challenge trying to place a border below the text as shown in the provided image. Below is the snippet of my Html code: <div class="Sectionheading"> ...