loader image
Angular Web Development

Bootstrap Modal Window In Angular Using Typescript

Hello, happy to see you here!  

In this blog, you’ll be learning the basic implementation of modal window/popup in Angular using Typescript.

Angular 2/4 or Typescript are bringing in the true Object Oriented Front-end development. First, we can start with Typescript,

What is Typescript?

Typescript angularTypescript is a programming language that is the syntactical superset of Javascript. Typescript being purely object-oriented and helps us to write clean and scalable javascript. When we are developing complex applications many developers find it difficult to write clean and object-oriented code in JS but with Typescript it becomes easy. Typescript also provides tools like advanced autocompletion, navigation, and refactoring. And angular is also written in Typescript because of the features typescript offers.

In Bootstrap we have so many features that are implemented by default, One such feature is modal popup/ modal windows.

Basic Structure of  Bootstrap Model in Angular

Bootstrap model in angular typescript


Angular 2 or 4 is a component-based framework with typescript, Components are major building blocks of it. A component can be defined as an independent cohesive block of code which has the required logic, view, and data as one unit. When written using TypeScript, a component is a TypeScript class decorated with @Component() decorator.

Now let us implement the above bootstrap modal window code in angular.



Next the model window code is implemented as the following :


ngClass or ngStyle are the built-in directives for angular, using them we will be able to dynamically update the HTML element. Now we have used ngStyle to show & hide the modal window.


 Display is a defined variable in angular typescript and by default it is none.


Next, For opening the model window, click the open modal() and change the display variable value as block.


Same as close the model window,


Finally, we have a nice backdrop to add to the CSS component.



Result :


And now the modal popup/ modal window will look like the following :


Finally, hope the blog helped you to implement a modal window/popup. If you have any doubts or queries while implementing please comment below. For more on Angular and web development follow Agira technologies. If you are looking for angular developers for your project? Hire Angular developer from Agira Technologies to build best web-apps at affordable rates. Our dedicated Angular developers are well-versed with all the updates and ensure top-notch web applications development to meet your business requirements.

Talk to our experts


The following two tabs change content below.


An ideal Full Stack Developer, having around 5+ years of experience in web development arena, expertise in AngularJS, Nodejs, PHP and also scoring 6 years of experience in Networking & Window servers. A perfect all-rounder has fondness to play diverse role. he always strives to match perfection and likely remains the best in whatever role he takes.

22 thoughts on “Bootstrap Modal Window In Angular Using Typescript”

  1. I have implemented the same code , but i am getting cannot find name ‘block’ error in component.ts . Can you please provide the solution.
    Thank you in advance.

    1. In the example code is missed the inverted commas for word ‘block’, should be openModal(){

  2. Thanks! l’m newbie developer. I don’t know angluar4 & typescript because I study jquery & javascript. This code is very useful. So, l clear my order in deadline.

  3. i have used you bootstrap modal popup but issue scroll. i have take 20 field in your boostrap modal scrolling is not working please give me solution as soon as.

    1. Hi Rohit,
      We can help you out but please post your sample code so that we can understand the issue that stopped scrolling function. Thank you!

  4. <!– –>
    Add a Customer
    First Name
    Last Name
    Mobile Number
    Email Address
    Profile Image

    Country Code
    Postal Code
    –Select Status–

Leave a Reply

Your email address will not be published. Required fields are marked *

Join our 30,000+ subscribers, never miss out anything on our latest blogs, tips, tutorials, updates & more.