Utilizing AngularJS ng-repeat and Bootstrap to showcase database items in columns

I am currently customizing a template for my MEAN app and I am trying to showcase some information retrieved from the database in three columns. However, I am facing an issue where the ng-repeat function is only displaying the data in a single column.

Below is the code snippet:

<div class="row mt-5">
  <div ng-repeat="woman in women">
    <div class= "col-md-4">
        <!--Card-->
          <div class="card">
              <!--Card image-->
              <img class="img-fluid" src="{{woman.image_url}}" alt="{{woman.name}}">
              <!--Card content-->
              <div class="card-body">
                  <!--Title-->
                  <h4 class="card-title">{{woman.name}}</h4>
                  <!--Text-->
                  <p class="card-text"> <h5>{{woman.field}}</h5> <br> {{woman.job}}</p>
                  <a href="#!/women/details/{{woman._id}}" class="btn btn-primary">Learn more</a>
              </div>
          </div>
          <!--/.Card-->
    </div>
  </div>
</div>

Currently, I am resizing the images to have a uniform size. Additionally, I am looking to only display a portion of the images in this view, with the full image being visible in the detailed view.

Thank you!

Answer №1

Take a look at this and confirm if it meets your requirements:

<body ng-app="test">
<div class="row mt-5" ng-controller="testCtrl">
  <div ng-repeat="woman in women">
    <div class= "col-md-4">
        <!--Card-->
          <div class="card flexcss">
              <!--Card image-->
              <img class="img-fluid" ng-src="{{woman.image_url}}" alt="{{woman.name}}">
              <!--Card content-->
              <div class="card-body">
                  <!--Title-->
                  <h4 class="card-title">{{woman.name}}</h4>
                  <!--Text-->
                  <p class="card-text"> <h5>{{woman.field}}</h5> <br> {{woman.job}}</p>
                  <a href="#!/women/details/{{woman._id}}" class="btn btn-primary">Learn more</a>
              </div>
          </div>
          <!--/.Card-->
    </div>
  </div>
</div>
</body>

CSS:

.flexcss{
  display:flex;
  flex-direction: row
}
.card-body{
  padding:5px;
}

JS:

var app= angular.module('test',[]);

app.controller('testCtrl', function($scope, $http) {
    $scope.women= [
      {
      image_url: 'https://upload.wikimedia.org/wikipedia/en/e/ed/Wonder_Woman_%282017_film%29.jpg',
      name:'wonder women',
      field:'war',
      job:'saviour'
     },
            {
      image_url: 'https://upload.wikimedia.org/wikipedia/en/e/ed/Wonder_Woman_%282017_film%29.jpg',
      name:'super girl',
      field:'war',
      job:'fighter'
     },
      {
      image_url: 'https://upload.wikimedia.org/wikipedia/en/e/ed/Wonder_Woman_%282017_film%29.jpg',
      name:'Bat Woman',
      field:'war',
      job:'fighter'
     }
      ]
  }

)  

https://codepen.io/shankkie/pen/QMmKxz

Answer №2

Make sure to use ng-src instead of src when you want to display images.

<img class="img-fluid" ng-src="{{woman.image_url}}" alt="{{woman.name}}">

DEMO

var app = angular.module('myApp',[]);
app.controller('myCtrl',function($scope){
  $scope.women = [
  {"_id":"5992b00cf8f760203378872f","name":"Ada Lovelace (Ada Byron)","birthDate":"10 de diciembre de 1815","deceaseDate":"27 de noviembre de 1852","field":"Mathematics","job":"Matemática y escritora, creadora del primer algoritmo para programar una máquina","bio":"Su padre fue el conocido poeta George Byron, y su madre, Anne Isabella Noel Byron, poeta y matemática. (...). Ada Byron se refería a sí misma como una científica poetisa y como analista (y metafísica)","image_url":"https://i.pinimg.com/736x/7b/db/e4/7bdbe44fda240b5992b2ce570e273719--kate-winselt-adrienne-bailon.jpg"},
  {"_id":"5992b00cf321360203378872f","name":"Jon right (Ada Byron)","birthDate":"10 de diciembre de 1815","deceaseDate":"27 de noviembre de 1852","field":"Mathematics","job":"Matemática y escritora, creadora del primer algoritmo para programar una máquina","bio":"Su padre fue el conocido poeta George Byron, y su madre, Anne Isabella Noel Byron, poeta y matemática. (...). Ada Byron se refería a sí misma como una científica poetisa y como analista (y metafísica)","image_url":"https://media.vanityfair.com/photos/57e15c417dd0d7d276c7cb7c/master/h_590,c_limit/angelina-jolie-vf-december-2014-ss02.jpg"}
  
  ];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
 <div ng-repeat="woman in women">
    <div class= "col-md-4">
        <!--Card-->
          <div class="card">
              <!--Card image-->
              <img class="img-fluid" src="{{woman.image_url}}" alt="{{woman.name}}">
              <!--Card content-->
              <div class="card-body">
                  <!--Title-->
                  <h4 class="card-title">{{woman.name}}</h4>
                  <!--Text-->
                  <p class="card-text"> <h5>{{woman.field}}</h5> <br> {{woman.job}}</p>
                  <a href="#!/women/details/{{woman._id}}" class="btn btn-primary">Learn more</a>
              </div>
          </div>
          <!--/.Card-->
    </div>
  </div>
</body>

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

Tips for designing a customizable color scheme for your website

Are you looking to implement a changeable color scheme for your website? Getting started can be daunting, especially if you're unfamiliar with sass. Would appreciate it if anyone could share some helpful tutorials or links? For example: example ...

Using Axios to fetch data and populating select dropdown options in a Vue component

I am currently working on integrating the response data values with my multiselect options. Although the console log displays the returned results, I'm facing difficulty in connecting them to my multiselect options. When I enter 'Day' into ...

Book a spot in IndexedDB storage

Currently, I am developing a diagnostics application that updates data to IndexedDB every three seconds. The data has a fixed size and anything older than a week is automatically removed, resulting in a maximum of 201600 entries. This simplifies the proces ...

AngularJS - "Refrain from replicating items in a repeater"

I am facing an issue with creating HTML textarea elements for each member of an array. Despite consulting the AngularJS documentation and attempting different track by expressions, I am unable to render them. The problem arises when a user inputs the same ...

Client-side validation with Jquery is failing to function properly

Currently, I am experimenting with the jquery.validate.unobtrusive.js plugin to dynamically generate form fields. Here is an example of how I'm creating a textarea field: var message = $("<textarea id='test'></textarea>"); $(mes ...

Using jQuery to determine if the child element is a <ul> tag

HTML: <ul class="menu"> <li><a href="http://example.com">Text</a> <ul> <li><a href="http://example.com">Text</a> <li><a href="#">Text</a> <li><a href="# ...

Express.js receiving JSON POST data with AngularJS incorrectly interpreted as keys instead of values

I am facing an issue while trying to make a POST request with JSON data from angularjs to node/express. The problem is that all the data is appearing in the KEY of the req.body instead of as key value pairs. Although I found a similar question addressing ...

I developed a compact application utilizing Node.js in tandem with Express framework

There is an issue with the GPA calculator app built using Node.js and Express. It works fine for a single user, but when multiple users try to use it simultaneously, the scores are being combined, resulting in incorrect values. I need to create an app that ...

Transferring data through Ajax, Jquery, and PHP: A seamless process

My goal is to develop an attendance button that adds +1 to the total number of people attending when clicked by the user. I am looking for a way to achieve this without having to refresh the page. Ideally, I would like to connect it to a database to upda ...

Issue with invoking Bracket-Shell bespoke Native (C++) Method

I'm currently working on developing a unique C++ function that can be invoked from JavaScript to resize the window. The necessary components are located in various files: Within appshell_extensions_platform.h: #if defined(OS_WIN) void ResizeWindow( ...

Extracting the content within HTML tags using regular expressions

There is a specific string structure that needs to be processed: <div class="myClass"> Some Text. </div> <div class="otherClass"> Some Text. </div> The task at hand involves parsing the div with myClass and replacing certa ...

Can you explain the variance between a DIV using display: inline-block versus a SPAN element?

Can you explain the distinction between a DIV using display: inline-block and a SPAN? Furthermore, what sets apart a SPAN with display: block from a DIV? ...

Error: The function or method save() has not been resolved

The function model.save() for mongoose is not being properly defined. models/genre.js 'use strict'; const mongoose = require('mongoose'); const Schema = mongoose.Schema; const GenreSchema = new Schema({ name: {type: String, requi ...

Reliable Dropdown Navigation Bars

Once I have successfully implemented three dynamic drop down menus using the combination of jQuery, AJAX, and PHP, the next challenge arises. After populating the dropdown menus based on user selections (e.g., selecting a value in the first dropdown menu ...

Manipulating Angular and Typescript to utilize the method's parameter value as a JavaScript object's value

I am currently working with Ionic, Angular, and Typescript, attempting to dynamically set the value of a location based on the parameter passed from a method. Here is the relevant code snippet: async fileWrite(location) { try { const result = a ...

Basic website layout

As someone who is new to web programming, I kindly ask for your patience :) I have a goal to design a page similar to the one linked below https://i.sstatic.net/HbJF3.png There are two key functionalities I am aiming for: 1) Clicking the button on the r ...

The process of dynamically populating data into a select element through an Ajax request using JavaScript may seem complicated at

I am working on an html page that includes two select options. The values for these select options are retrieved from a Servlet via an ajax call in the onclick() function. However, I am encountering an issue where the data is not populating into the sele ...

Unique twist on the Bootstrap grid: perfectly centered

I'd like to design a 12-column Bootstrap grid with specific colors. The header should be light blue, the body in green, and the footer orange against a grey background. I want the grid to be centered on the screen with horizontal light blue stripes m ...

Synchronizing validation processes across both front-end and back-end applications

How do you ensure validations remain synchronized between front-end and back-end teams when working with laravel? While I found some information in this post, I am curious about how it specifically applies to laravel. I came across the laravel js validat ...

Troubleshooting: Issue with displaying PHP data on an AngularJS table using JSON through jQuery AJAX

I've been encountering an issue while trying to display data from a database on my HTML page using Angular and JSON. Despite the browser being able to read the database, it fails to show the data. Can anyone shed some light on why this might be happen ...