Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
100 views
in Technique[技术] by (71.8m points)

How to set text color in Angular-Material?

I want to set one word in a sentence to have md-primary color, and another word to have the accent color. I assumed something like this:

<div>
    Hello <span class="md-primary">friend</span>. 
    How are <span class="md-accent">you</span>?
</div>

But those classes work only for some specified components.

What's the way to do it?

question from:https://stackoverflow.com/questions/28487327/how-to-set-text-color-in-angular-material

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was just able to do this using Angular Material 1.1.0.

You use the md-colors directive similar to how you would ng-class:

<span md-colors="{color:'primary'}">...</span>

The above code will color the text the primary color. The object that you pass to md-colors uses the key as the css property (i.e. 'color', 'background', etc) and the value as the theme and/or palette and/or hue you want to use.

Source Docs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...