In this tutorial, You will learn about how to use data types in Angular 5 application. Here we will talk about the useful data types available in TypeScript. If you are new to Angular then please also visit below Links Part1: Create your first Angular 5 application and Part2 : How does Angular 5 works?
Useful Data Types( TypeScript)
- String
- Number
- Array
- Any
- Boolean
- Tuple
- object
- Null
- void
import { Component } from '@angular/core';import { Employee } from './Employee';@Component({selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.scss']})export class AppComponent {name: string;age: number;numArray: number[];strArray: Array<string>;dynamicValue: any;IsTrue: boolean;tupleVal: [string, number, boolean];student: object;employee: Employee;constructor() {this.name="Ashish";this.age = 52;this.numArray = [10, 11, 20];this.strArray = ["Ashish", "Kumar", "Tiwary"];this.dynamicValue = 10000;this.IsTrue = false;this.tupleVal = ["Ashish", 45, true];this.student = { name: "Ashish", age: "45", email: "a@b.com" }this.employee = new Employee();this.employee.Name = "Rose";this.employee.Salary = 52000;this.employee.Department = "Development";this.employee.IsActive = true;}Test(mynum: number,str:string): number {return}}
Component.Html Code
<div style="margin:3% 10% 10% 10%;border:2px solid gainsboro;padding:2% 2% 2% 2%; "><ul><li>Name: {{name}}</li><li>Age:{{age}}</li><li>Number Array: {{numArray}}</li><li>String Array: {{strArray}}</li><li>Dynamic value: {{dynamicValue}}</li><li>Is true: {{IsTrue}}</li><li>Tuple:{{tupleVal}}</li><li>Student Object:{{student|json}}</li><li>Employee Class: {{employee|json}}</li></ul><ul><li *ngFor="let arr of strArray">{{arr}}</li></ul><router-outlet></router-outlet></div>
Employee.ts Class
export class Employee {Name: string;Salary: number;Department: string;IsActive: boolean;}
For more details please watch above video.
You are done! Please share, Like, Comment
14 comments:
Thanks for sharing the valuable information.
Angular JS Online training
Angular JS training in hyderabad
I would definitely thank the admin of this blog for sharing this information with us. Waiting for more updates from this blog admin.
Oracle Training in Chennai | Certification | Online Training Course | Oracle Training in Bangalore | Certification | Online Training Course | Oracle Training in Hyderabad | Certification | Online Training Course | Oracle Training in Online | Oracle Certification Online Training Course | Hadoop Training in Chennai | Certification | Big Data Online Training Course
Improve coding skills with professional
Python training.
Includes hands-on practice.
Best for career growth.
Learn platform skills, configuration, and automation with a salesforce admin course onlinedesigned for real-world business needs.
This salesforce admin traininghelps build real-world expertise for configuring workflows, reports, and automation efficiently.
Advance your career with salesforce admin certification classes designed to build real-world Salesforce expertise.
Experienced professional specializing in salesforce developer classes building scalable Apex, Lightning, and integration solutions.
"Join power bi live training to master data visualization and business analytics in real time. Gain hands-on experience with dashboards, reports, and advanced Power BI features directly from experts."
"Enhance your career with sfdc admin course designed to equip you with hands-on Salesforce administration skills."
"Enhance your career with sfdc developer course designed for both beginners and professionals. Learn to build, customize, and deploy Salesforce applications with real-world projects and hands-on training."
Become a professional Java Full Stack Developer—Java, Spring Boot, front-end, and real-world apps.java coaching online
Enhance your design career with UI/UX training: wireframing, prototyping, user research, and Figma. ui and ux training
"Enhance your career with sfdc admin course
designed to equip you with practical Salesforce administration skills. Learn to manage users, automate processes, and optimize CRM workflows effectively."
"Join power bi live training
to master data visualization and analytics in real-time. Gain hands-on experience and expert guidance to boost your business intelligence skills."
Post a Comment