Angular Typescript Variable Declaration

0

Typescript Variable Declaration in Angular



We can declare the different type of variable in angular it supports following type of data.

  1. Introduction
  2. Boolean
  3. Number
  4. String
  5. Array
  6. Tuple
  7. Enum
  8. Any
  9. Void
  10. Null and Undefined
  11. Never
  12. Object    
  13. Complete Program of Angular JS typescript

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-sharukh',
  templateUrl: './sharukh.component.html',
  styleUrls: ['./sharukh.component.css']
})
export class SharukhComponent implements OnInit {
   a:number=10;
   b:number=20;
   c:number=0;
   s:string
   s1:string 
   b1:boolean
   //arr:number[];
   arr:Array<number>[];
  
   
  constructor() {
    this.c=this.a+this.b
    this.s= "hello"
    this.s= 'hi'
    this.s1 = `${ this.s } ram is going to market`
    this.arr = [11,23,34,56,67]
    this.b1=false;
    //this.tpl=['rno',1001];

  }

  ngOnInit() {

  }

}

html code
<p>sharukh not works!</p>
{{c}}
{{s}}
{{b}}
{{s1}}
{{arr}}
{{tpl}}

إرسال تعليق

0تعليقات

POST Answer of Questions and ASK to Doubt

إرسال تعليق (0)