Mastering the art of horizontal scrolling within an angular material layout=row

I am attempting to create a slider using only a horizontal scrollbar with cards inside. In order to do this, I am trying to scroll the layout="row" within an ng-repeat.

Check out my codepen here

<body ng-app="myApp" ng-cloak ng-controller="ProductController">
  <md-content class=" md-padding " layout="column ">
    <div layout="row">
      <div flex="33" ng-repeat="y in [1,2,3,4,5,6,7,8,9,10,11] ">
        <md-card>[ flex = 33 ]
        <md-card>
      </div>
    </div>    
  </md-content>
</body>

I can't figure out what's going wrong with it.

Thank you!

Answer №2

Creating a horizontal scroll effect requires the content width of an element to be larger than its actual width. To achieve this, you must determine a specific number to set as the content's width. (I opted for 300vw)

Here is an example:

<body ng-app="myApp" ng-cloak ng-controller="ProductController">
  <md-content class=" md-padding " layout="column ">
    <div layout="row" style="width: 300vw;">
      <div flex ng-repeat="y in [1,2,3,4,5,6,7,8,9,10,11]">
        <md-card>[ flex = 33 ]
          <md-card>
      </div>
    </div>
  </md-content>
</body>

It's important to note that using flex="33" will attempt to distribute 3 elements across the parent's width equally at 33% each. However, if there are more than 3 elements, they will fill the width evenly. Therefore, simply using the flex directive will yield the same outcome.

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

It’s not possible for Typescript to reach an exported function in a different module

Having trouble referencing and using exported methods from another module. I keep getting an error that says 'There is no exported member in SecondModule'. module FirstModule{ export class someClass{ constructor(method: SecondModule ...

What is the process for retrieving user information following REST authentication on the client side?

In my setup, I have a Spring REST backend that communicates with an Angular frontend. For authentication, the frontend sends a POST request to the "/login" URL with the username and password in the request JSON body. The backend responds with an OK code, ...

NG-model not visible to AngularJS Controller's filter

Finally, the code is working perfectly. It's a mystery to me. I created a custom filter to use with ng-repeat. The code is implemented within a Controller ... .controller('makeOrderController', function ($scope, $timeout, $ionicLoading) { ...

Combining multiple requestBody in an AngularJS http.put request

Can AngularJS http.put method send multiple requestBody parameters to the server? Here is an example of my frontend Angular put method: function XY() { return $http.put(url, { data1: data1, data2: data2 }); And this is how my backend method is struct ...

Angular animations: triggered by user interaction

I'm encountering some difficulties with animating elements in my Angular application. The issue involves a grid made up of cells (created using ng-repeat). What I'm aiming to achieve is a simple animation: when a cell is clicked, it should disapp ...

What is the best way to refresh an Angular model containing nested data?

This week, I started working on a proof of concept with Angular Material where I have a table displaying nested data: <table> <thead> <tr> <th colspan="2">Employee Name</th> <th>Ovr&l ...

How can I pass a parameter to my MEAN application using a clean and readable URL

Seeking suggestions for passing a parameter into a MEAN application without compromising the URL aesthetics. I must find a solution that does not involve client-side storage. The following Express route effectively integrates the parameter into the Angular ...

What is the best method to retrieve a JSON record by its specific ID using Angular's AJAX functionalities?

I've been working on a function within my service that retrieves data function getSomeData() { return $http .get('/someData.json') .then(itWorked) .catch(onFail); Currently, this function returns all the records from the J ...

Issues with nested array filtering in JS/Angular causing unexpected outcomes

I am faced with a particular scenario where I need to make three HTTP requests to a REST API. Once the data is loaded, I have to perform post-processing on the client side. Here's what I have: An array of "brands" An array of "materials" An array o ...

Can AngularJS Filters be used to convert a number into a string, but not the other way around?

After researching Angular JS filters, I discovered that the number filter is used to format a number as a string. However, there doesn't seem to be a built-in filter for converting a string to a number. In an attempt to solve this issue, here is so ...

Retrieve data from Last.fm API by utilizing both Node.js and Angular framework

I am currently working on implementing the node-lastfmapi track.search method into my project. I have successfully retrieved the results, but I am facing challenges in integrating them into the front end using Angular. My backend is powered by mongoDB and ...

Modifying the dimensions of mat-card in Angular Material

https://i.stack.imgur.com/CP16N.png I am struggling to make both components the same height, similar to the left form. I have tried adjusting margins and padding but nothing seems to work. Below is the HTML code for the parent element: <mat-tab label= ...

Pull information from API and populate a dropdown menu in an Angular material select input

I am facing an issue with displaying data from an API in a mat select input field. I have tried to iterate over the data using a for loop but it is not working as expected. Can someone help me figure out how to properly populate the mat select input with d ...

Issue with Cordova contact plugin functionality

Upon calling the specified function, I encounter the following error message: "TypeError: Cannot read property 'pickContact' of undefined" $scope.pickContact = function() { navigator.contacts.pickContact(function(contact) { if(co ...

Tips for saving the status of an accordion controlled by an angular directive

I am currently utilizing the accordion directive from angular-bootstrap. My goal is to save the is-open attribute of this accordion, so that when users navigate to another page on the website, the state of the accordion (i.e. is-open) remains unchanged. ...

Filtering input for multiple header columns in an Angular table

A complex Angular table structure has been implemented with three columns. Each column header contains an input field for Stock Number, Case, and Availability. Users have the flexibility to search using a Single Input (Stock Number OR Case OR Availability ...

Having trouble locating the module recommendations on my Angular 1.6 app while using Browserify

My app is not able to find suggestions.module even though it loads am-suggestions-lib.js. I am using angular 1.6 and browserify, but I can't figure out what I'm doing wrong. Here are all the relevant files: View the tree here suggestion.module. ...

Sending information to an Ionic popover within an ng-repeat loop

Struggling to integrate Ionic Popover into my application under ng-repeat. How can I pass a parameter to it? <p ng-repeat="query in ctrl.timesheet">query.Name<button ng-click="openPopover($event)">Open Popover</button></p> <scr ...

When the down key is pressed in a textarea, choose the list item

I have HTML similar to the following <div class="row"> <textarea id="txtArea" ng-model="input" ng-change="handleOnChange(input);getSearchField(input);" ng-click="search(input)" ng-focus="search(input);" ...

What is the process for uploading files using AngularFire on Firebase Storage?

Despite watching multiple videos and tutorials, I am encountering a 403 error while working with Angular 1. To solve the issue of ng-model not supporting files, I created an Angular directive named file-model: app.directive('fileModel',['$ ...