Angular 2 is the latest framework for building web applications using typescript. Recently, angular team is skipped the version 3.x because, router package is shipped with 3.x previously, so instead of putting into 3.x, choose to move to 4.x.

Tuesday, 15 November 2016

Templates in Angular 2

Angular 2.x templates are similar to Angular 1.x templates  except few syntactical changes.

HTML :

Angular uses HTML language for templates.
<div>
         <h1>Angular Tutorials by Srinivas Nidadavolu</h1>
</div>

Interpolation : 

 Angular uses expression (Double curly braces)

<div>
         <h1>Angular Tutorials by {{data.name}}</h1>
</div>

it print 

Angular Tutorials by Srinivas Nidadavolu

<p>5+5 Sum is {{5+5}}</p>

it print 

 5+5 Sum is 10


Another example :

lets create a basic component and it has name property that we are going to use in our template.

@Component({
 selector:'my-app',
 template:'my-app.html'
})

export class MyAppComponent {
name = 'Srini'
}

in the template , we can use name

<p>{{name}}</p>

it prints in the html page

Srini




 




10 comments:

Labels

Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts