Struggling to make Angular Material flex work properly for layout placement

Currently, I am working with an Angular module that is referenced in the index.html file. The template file associated with this module is outlined below:

<div id="{{$ctrl.link}}" class="container-fluid">
 <div layout="row">
  <div flex layout="row" layout-fill style="height:100%;">
   <div flex="40">
    <img src="{{$ctrl.image}}" height="600px"></img>
   </div>
   <div flex="40">
      Other Flex part
   </div>
   <div flex="20">
   </div>
  </div>
 </div>
</div>

The issue I am currently facing is that the two divs are supposed to stack up in rows as follows: div | div | div. However, instead of stacking up horizontally, the divs are just stacking up vertically.

Answer №1

There don't appear to be any HTML issues in your code (aside from img being a self-closing tag).

I've made some simplifications to your code.

Check out the updated code on CODEPEN


angular.module('myApp', ['ngMaterial'])
<body ng-app="myApp">
  <div id="{{$ctrl.link}}" class="container-fluid">
    <div layout="row">
      <div flex layout="row">
        <div flex="40">
          <img src="//placehold.it/200" />
        </div>
        <div flex="40">
          Other Flex part
        </div>
        <div flex="20">hey
        </div>
      </div>
    </div>
  </div>
</body>

P.S. - Make sure you are using ngMaterial in your angular.module.

Answer №2

Angular Material is new to me, but after browsing through the documentation, it appears that this code snippet should do the trick:

<div id="{{$ctrl.link}}" class="container-fluid">
  <div layout="row">
    <div flex="40">
      <img src="{{$ctrl.image}}" height="600px">
    </div>
    <div flex="40">
      Other Flex part
    </div>
    <div flex="20">
    </div>
  </div>
</div>

It seems like the issue might be arising from nesting a row within another row, causing only one column to show up in the parent row as it's the only child element.

<div layout="row">
  <div flex layout="row" layout-fill style="height:100%;">

Please Note:

I'm not entirely certain about where to incorporate the use of layout-fill. You may want to experiment with adding it to either the main row itself or to specific columns that need filling.

Additionally, keep in mind that this markup is incorrect:

<img src="{{$ctrl.image}}" height="600px"></img>
(<img> tags are self-closing).

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

Guide on invoking an Angular 1.5 component with a button press

Having just started learning Typescript, I'm struggling to figure out how to call my Angular component "summaryReport" on a button click. Here's a snippet of my code: Let's say I have a button that should call my component when clicked with ...

Strange Phenomenon: Website Appears Enlarged When Accessed through Server

Similar Question: Why does my website appear smaller on a live server than when deployed locally? After reviewing the answer to the similar question linked above, I still found myself facing the same issue with no resolution. My problem is that the webpa ...

display a message of achievement within the $http response

I am attempting to display a success message in the HTTP response for 3 seconds before redirecting the page. Here is the code snippet: <body ng-app='myApp' ng-controller='myCtrl'> <div class="col-lg-12 col-sm-12 col-xs-12 ...

Having trouble connecting angular repository data with promise

I have been trying to implement the repository pattern in my Angular application. I can see that the JSON data is successfully retrieved over the network when I call my repository, but I am facing issues with binding it to my view. I have injected the rep ...

Using jQuery to serialize parameters for AJAX requests

I could use some help figuring out how to set up parameters for a $.ajax submission. Currently, I have multiple pairs of HTML inputs (i pairs): > <input type="hidden" value="31" name="product_id"> <input > type="hidden" value="3" name="qua ...

Conflict with iScroll

When using an HTML5 template in Mobile Safari on iPad, I encountered an issue with a div containing iScroll. Within this div, there is a jQuery function within an if/else statement which tests if the user is tapping outside of the iScroll div and fades it ...

Buttons experiencing issues with modal class functionality

I have a form that needs to be filled out. <form action="../massmail.php" method="post"> <label>Period:</label> <div class="form-inline"><input class="form-inline input-small" name="month" type="text" placeho ...

I am experiencing some challenges with my code as the Jquery Ajax function does not seem to be functioning correctly. Can

I am trying to incorporate a for loop (or `do/while loop) in my code, but unfortunately, it is not functioning as expected. The current setup is only working for a single item, and the goal is to have multiple items on a single invoice by utilizing the lo ...

Facing issue with Codeigniter AJAX form where post data is not being collected

I am attempting to send a newsletter form to Codeigniter using AJAX. I have implemented CSRF protection, but I am facing issues with retrieving the posted values and receiving the response correctly. Here are the various scenarios: When I include name="e ...

Learn how to utilize ng-class to assign an ID selector to HTML elements

In my code, I have an icon that is displayed conditionally using ng-class. I am looking to include ID's for both the HTML elements. <i ng-show="ctrl.data.length > 1" ng-class="{'glyphicon glyphicon-chevron-down': !ctrl.isOpen, ...

Executing a jQuery function from a PHP file

Trying to use Messi.js to display a pop-up box in case of input errors in a form. The PHP file named add email is utilized for this purpose: <?php /ini_set('display_errors',1); //ini_set('display_startup_errors',1); //error_reportin ...

Creating a basic modal with jQuery

I am currently using SimpleModal with jQuery, and I have a single confirmation dialog set up. When the user selects 'Yes' in the dialog box, I need to load my.php within that same dialog. Despite my efforts, I'm still brainstorming for poten ...

Find out the index of a div within an array

Curious about determining the position of a div in an argument? For instance, if there are multiple divs with the same name: <div class="woot"></div> <div class="woot"></div> <div class="woot"></div> <div class="woot ...

Adjust the scrollTop of the tab-content when navigating between different tabs

When I scroll through the content of menu1 and then click on the menu2 tab, the content for the menu2 tab is displayed. However, I am facing an issue with changing the scroll position of the tab content so that it is visible from the top. I attempted to u ...

invoking a function in javascript from react

Currently, I am grappling with the task of invoking a JavaScript function from within React while adapting a "React" based "Menu" onto some existing jQuery functions. Below you can find my code for the menu: class Menus extends React.Component{ co ...

Adjust the video's position to ensure it scales properly on mobile devices

I'm facing a coding challenge with the following snippet: https://codesandbox.io/s/cool-sunset-pe8pgh?file=/src/styles.css My goal is to scale the video on mobile devices without sacrificing any part of the video element. What would be the best appro ...

Creating sitemaps for multi domain websites using NextJS

We are implementing a next-sitemap package to generate sitemaps for our Next.js pages located in the /pages directory. For pages that come from the CMS, we use server-sitemap.xml with SSR. Despite having 6 different domains, we manage them within a single ...

JS receiving a reference to an undefined variable from Flask

I referenced this helpful post on Stack Overflow to transfer data from Flask to a JS file. Flask: @app.route('/') def home(): content = "Hello" return render_template('index.html', content=content) HTML <head> ...

What's going on with this unresponsive button in the login system?

I am facing an issue where my code does not respond when I click the login button with the correct login details. Following some suggestions from the comments, I have modified the code to include an onClickHandler function. However, I am unsure which arg ...

Using jQuery to access the value of the CSS property "margin-left"

I created a JavaScript game with moving divs that have different transition times. The game includes a function that is called every 1/100 seconds, which checks the position of the divs using: $("class1").css("margin-left") Here's the strange part: ...