Angular Material Design: how to automatically use all the built-in UI icons? - angularjs

I am trying an Angular app project with the Google Angular Material library.
Added #master branch via Bower as directed. Linked the CSS and JS fils from Bower Components to my index page as directed.
Works as expected, except things like dialogs have SVG icons, which are defined in the html an pathed as so:
<md-icon md-svg-src="img/icons/ic_close_24px.svg" aria-label="Close dialog"></md-icon>
Which is not in my project nor the Bower Components folder...
And therefore gives me a 404:
How should i configure the project to get all the images as expected? I'd create that img/icons path if I knew where to get all possible icons...
OK, I have added this to my app.js:
angular.module('app').config(function($mdIconProvider) {
// Configure URLs for icons specified by [set:]id.
$mdIconProvider
.defaultIconSet('bower_components/material-design-icons');
});
But still a 404... the bower download is like 200 mb of icons... do I need ot list each icon I want to link? As in .icon("menu", "./assets/svg/menu.svg", 24)

I did have the same problem and I was not able to find a proper answer.
After some research, I've finally found something !
https://github.com/angular/material/issues/1668#issuecomment-156368247
As "ranbuch" said, once you've loaded the font Material Icons (either from a CDN or locally), you can just use this directive :
<md-icon aria-label="Menu" class="material-icons">menu</md-icon> and replace menu by the name of the icon you're looking for.
This way, it allows you to skip the long listing of every svg.
PS : There's also a good stackoverflow answer here.

Copy all the selected svg icons you need to images/icons folder inside your application and then use them as below :
<md-icon md-svg-src="images/icons/leftArrow.svg"
ng-click="previous()" class="icon-color">
</md-icon>
If you are planning to use lots of icons, use css font icons. One css file will load all your icons, instead of multiple svg links.
Check section 1 here of material icons guide

Related

Bootstrap component not working with react app

I have created a React Application and copied navbar from bootstrap component. I also added cdn files at index.html file. Also changed changed class to className but still but when run I get error with failed to compile and cursor is placed on data-toggle="colapse". upon removing this line it moves to next one. but its not working. .
working with bootstrap in react is not simple, it is easier to use React-bootstrap.
https://react-bootstrap.github.io/
you then just download the npm package and import the buttons and other options you want.
If you want to go about doing it this way, then you would need to use <button className="bootstrapclass">hello</button>
or specifically
<button className="btn btn-secondary">hello</button>
outside of that, there is no way to use bootstrap.
it is advisable that you share your code, so people can see what the mistake is.
The error was because of attaching cdn at outside the body. I resolved this by placing cdn of CSS and JS at just before the closing body tag.

How to use Material Design Icons in Angular app

I am using angular material design for giving responsive design to my AngularJS app. I am using material design icons which I install using:
bower install material-design-icons
Then I declare the css as CDN link which is:
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
I am using the icons by:
<i class="material-icons md-36 md-dark">person</i>
My problem is that there is no way to include css from bower_components. I want to replace CDN source to css with local source from bower_components. But I don't see any css file downloaded in my bower_components.
This is how my bower_components/material-design-icons directory look like:
I followed instructions given in Material icons guide, but couldn't figure out about including CSS from bower_components.
In your materil-design-icons folder you have the iconfont folder, which contains your required CSS files.
There are 2 types of material design icons .... font icons and svg icons
The markup you have shown is for font icons
The bower package for the icon fonts is material-design-iconfont
Try bower install material-design-iconfont ---save
If I understood your question, you're trying to use material design on your web app. the package material-design-icons is just the icons info.
I believe that, to achieve what you're looking for, you should get the bower google package material design lite info, they also provide a set of templates
There's also a bootstrap material design.

How to get Bootstrap Calendar Default look using Angular Bootstrap

How to get Bootstrap default datepicker look and feel using Angular UI Bootstrap
Angular UI Bootstrap calendar view :
http://plnkr.co/edit/?p=previewenter code here
What I want :
https://eonasdan.github.io/bootstrap-datetimepicker/
The Angular UI Bootstrap project has no CSS, rather we defer directly to Bootstrap's CSS. You can override Bootstrap's default themes or download one of the literally thousands of other BS themes out there.
You are trying to use the CSS of one project as a replacement for CSS in another. This usually requires quite a bit of manual work. As you can see here, the project you want to imulate uses its own CSS.

Angular Material - Text now showing

I just started using Angular for university purpose and I wanted to start easy so I just copied some stuff for the official Angular material page into my editor.
(Used bower to install angular-material "bower install angular-material")
This is my code (image, because they don't like HTML code here):
http://imgur.com/pr8YYvN
The button is showing up, but the fancy "click on" animation doesn't work and I cannot see the button description neither!
It was me who add the "." in front of every src/href (the button is not there on the original angular example page, but without the dot, the font won't even be in material style but just standard e.g. Arial)
Where is the problem, did I forget something?
Thanks in advance!
You are using the controller MainCtrl in your application, but you never actually created a MainCtrl in your JS. You also reference YourController in your JS, which is also not declared anywhere.
I recommend to read the error messages angular is giving you in the console.

angular-bootstrap accordion won't open

Plunker: http://plnkr.co/edit/Sjfb3Esx1NsjwaYGLMGZ?p=preview
Accordion is in the servers tab.
The plunker actually works. My real app does not. The only thing that plunker is not really replicating is the ui-router stuff. On my actual app the accordion won't open. Other questions on SO say that ui.bootstrap is not included and that fixed their problem. I do have ui.bootstrap included though.
I've also tried copying and pasting the example from http://angular-ui.github.io/bootstrap/ that doesn't work either.
I'm at a loss for what else to look for.
More info:
I'm not getting any errors. Also other ui-bootstrap directives work just fine. I'm using tabs on this same page, and modal and dropdown work on other pages.
there is an issue with some version of angular-ui, the js assumes that one atleast one accordion is open and tries to calculate width. But bootstrap hides all accordions. So try displaying one accordion through css, i.e. set the display property of the accordion.
As per my comment:
It's my template. Somehow my template files are out of sync with the js files. In the template it is calling ng-click="toggleOpen()" which does not exist in my code. When I roll that back to ng-click="isOpen = !isOpen" everything works as expected. I need to figure out why my templates and js files are out of sync.
I installed ui-bootstrap using bower which does not include template files. I need to disable template caching during development so I can't use the tpls code. I downloaded the template directory from github and some of the templates simply do not match up with the version of code that bower downloads. I updated the template file to an older version that correctly matches the code from bower. Everything works now.

Resources