Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

First Create a Component using 

ng g c fact

After Create HTML Page
<p>factapp works!</p>

<input type="text" name="a" [(ngModel)]="a" />
<br><br>
<input type="button" name="btnclick" value="Click" (click)="factorial()">
<br>

<div [innerHTML]="f"></div>

Create a TypeScript:-

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

@Component({
  selector: 'app-factapp',
  templateUrl: './factapp.component.html',
  styleUrls: ['./factapp.component.css']
})
export class FactappComponent implements OnInit {
  a=5
  f=1
  i=1
  s=''
  constructor() {

   
  }

  ngOnInit() {
  }
  factorial()
  {
   
   
     for(this.i=1;this.i<=this.a;this.i++)
      {
         this.f=this.f*this.i

      }
  }
}

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post