Skip to main content

how to use ngStyle in angular

The NgStyle directive lets you set a given DOM elements style properties.

One way to set styles is by using the NgStyle directive and assigning it an object literal, like so:

HTML
COPY<div [ngStyle]="{'background-color':'green'}"></<div>

This sets the background color of the div to green

Comments

Popular posts from this blog

Create module and component in angular by CLI

To create a component as part of a module you should ng g module newModule  to generate a module, cd newModule  to change directory into the  newModule  folder ng g component newComponent  to create a component as a child of the module.

Difference between full stack developer and minstack developer

 Full stack  Developer is that person who can develop client and server side applications like client means fronthand UI(html , CSS, angular materials , bootstrap etc) interface that communicate to server . Server means where handle the client request and create business logic and prepare the database that is server part . In simple and sort language server is a backhand  part. Who knows server side languages like java ,PHP , .net ,nodejs python etc  A minstack is that developer who knows only JavaScript. Based  application programmer like as nodejs, angularjs , mongodb expressjs , reactjs etc 

How to display text in angular component?

Let’s take an example and understand more about Data Display. In our example, we will look at displaying the values of the various properties in our class in an HTML page. Step 1  − Change the code of the app.component.ts file to the following. import { Component } from '@angular/core' ; @Component ({ selector : 'my-app' , templateUrl : 'app/app.component.html' }) export class AppComponent { TutorialName : string = 'Angular JS2' ; appList : string [] = [ "Binding" , "Display" , "Services" ]; } Following points need to be noted about the above code. We are defining an array called appList which of the type string. We are defining 3 string elements as part of the array which is Binding, Display, and Services. We have also defined a property called TutorialName which has a value of Angular 2. Step 2  − Make the following changes to the app/app.component.html file w...