Basic Angular material layout/flex example doesn't work


Onestone

I tried a basic layout/flex example from Angular's material design demo site:

https://material.angularjs.org/latest/layout/container

But no matter what I do, it doesn't work as instructed, only showing the four inner divs below each other at 100% width. I've tried modifying the code so that the columns are 50% wide, but it still doesn't work. Here is my code:

<div layout="column">
    <div style="background-color: #3e8f3e" flex="50">First item in column</div>
    <div style="background-color: #00b3ee" flex="50">Second item in column</div>
</div>

<div layout="row">
    <div style="background-color: #eea236" flex="50">First item in row</div>
    <div style="background-color: #ce8483" flex="50">Second item in row</div>
</div>

Here is the output:

enter image description here

Any ideas?

Here is a jsfiddle:

https://jsfiddle.net/v42grc01/1/

Little Lamb

You're missing the opportunity to include Angular Material 's dependencies and initialize the app and controller - see demo below:

angular.module('app', ['ngMaterial']).controller('ctrl', function() {});
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.9/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.js"></script>


<div ng-app="app" ng-controller="ctrl">
  <div layout="column">
    <div style="background-color: #3e8f3e" flex="50">First item in column</div>
    <div style="background-color: #00b3ee" flex="50">Second item in column</div>
  </div>

  <div layout="row">
    <div style="background-color: #eea236" flex='50'>First item in row</div>
    <div style="background-color: #ce8483" flex='50'>Second item in row</div>
  </div>
</div>

Related


Basic Angular material layout/flex example doesn't work

Onestone I tried a basic layout/flex example from Angular's material design demo site: https://material.angularjs.org/latest/layout/container But no matter what I do, it doesn't work as instructed, only showing the four inner divs below each other at 100% widt

Basic Angular material layout/flex example doesn't work

Onestone I tried a basic layout/flex example from Angular's material design demo site: https://material.angularjs.org/latest/layout/container But no matter what I do, it doesn't work as instructed, only showing the four inner divs below each other at 100% widt

Basic Angular material layout/flex example doesn't work

Onestone I tried a basic layout/flex example from Angular's material design demo site: https://material.angularjs.org/latest/layout/container But no matter what I do, it doesn't work as instructed, only showing the four inner divs below each other at 100% widt

Basic Angular material layout/flex example doesn't work

Onestone I tried a basic layout/flex example from Angular's material design demo site: https://material.angularjs.org/latest/layout/container But no matter what I do, it doesn't work as instructed, only showing the four inner divs below each other at 100% widt

MEAN stack, Angular basic example doesn't work

Gu Hanjun I am new to MEAN Stack. I set an example from many websites. But I can't go further. Here is the problem. My webserver can send index.html and other js files. But simple angular app won't work. Here is the code. index.html <!DOCTYPE html> <html> <hea

Angular material doesn't work

Yass Ikrou I want to use angular material in my AngularJS application, so I downloaded all its dependencies: <script src="bower_components/hammer/hammer.js"></script> <script src="bower_components/angular/angular.min.js"></script> <script src="bower_components

Angular material doesn't work

Yass Ikrou I want to use angular material in my AngularJS application, so I downloaded all its dependencies: <script src="bower_components/hammer/hammer.js"></script> <script src="bower_components/angular/angular.min.js"></script> <script src="bower_components

Angular material doesn't work

Yass Ikrou I want to use angular material in my AngularJS application, so I downloaded all its dependencies: <script src="bower_components/hammer/hammer.js"></script> <script src="bower_components/angular/angular.min.js"></script> <script src="bower_components

Angular material doesn't work

Yass Ikrou I want to use angular material in my AngularJS application, so I downloaded all its dependencies: <script src="bower_components/hammer/hammer.js"></script> <script src="bower_components/angular/angular.min.js"></script> <script src="bower_components

Bootstrap Colorpicker basic example doesn't work

Jay D. I want to use colorpicker plugin for bootstrap : https://farbelous.io/bootstrap-colorpicker/index.html It uses Bootstrap 4 and Jquery When trying the very basic code sample posted by the developer in my website or JS Fiddle, the color picker doesn't wor

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Basic click example doesn't work

PPJN Here is a very basic ng-click example. I can't seem to get it to work. Not sure what the problem is. I swear I've used Angular before! Here is a jsbin: JS Bin <!DOCTYPE html> <html ng-app> <head> <meta charset="utf-8"> <meta name="viewport" content="w

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Bootstrap Colorpicker basic example doesn't work

Jay D. I want to use colorpicker plugin for bootstrap : https://farbelous.io/bootstrap-colorpicker/index.html It uses Bootstrap 4 and Jquery When trying the very basic code sample posted by the developer in my website or JS Fiddle, the color picker doesn't wor

ngOptions doesn't work, even with basic example

Newman I'm very new to Angular and a little bit overwhelmed. From what I understand, I have a component where I can display similar data {{ this }}and it works fine. Now, I want to select the data located in component.ts. It's an array of strings: private stra

Boost Python basic example doesn't work

username Try the simplest Hello World example from the Boost Python quickstart #include <boost/python.hpp> char const* greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } Comp

MPI basic example doesn't work

username I am trying to understand the meaning of the following example: #include "mpi.h" #include <stdio.h> int main(int argc, char *argv[]) { int numtasks, rank, dest, source, rc, count, tag = 1; char inmsg, outmsg = 'x'; MPI_Status Stat; MPI_Init(

Bootstrap Colorpicker basic example doesn't work

Jay D. I want to use colorpicker plugin for bootstrap : https://farbelous.io/bootstrap-colorpicker/index.html It uses Bootstrap 4 and Jquery When trying the very basic code sample posted by the developer in my website or JS Fiddle, the color picker doesn't wor

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start

Basic Spark example doesn't work

Krzysiek Setlak I'm learning Spark and want to run the simplest possible cluster of two physical machines. I've got all the basic setup done and it looks fine. The output of the autostart script looks like this: [username@localhost sbin]$ ./start-all.sh start