Angular2 Typescript Customized Alert

Discussão em 'Angular' iniciado por user6705109, Dezembro 8, 2024.

  1. user6705109

    user6705109 Guest

    I am totally new to Angular2, And I am stuck on how to create an customized alert like this: check this alert box here

    Since I am new to Angular2 concepts , I dont know how to use this code in my angular2 app in which I made a table with submit button. I want to create an alert on submit button.

    Here is the UI :

    [​IMG]

    Here's my table.component.ts:

    import {Component, NgModule } from "@angular/core";
    import { BrowserModule } from '@angular/platform-browser';
    import {Http} from "@angular/http";

    @Component({
    selector: 'demo',
    templateUrl: './app/table/table.component.html'

    })

    export class TableComponent{

    public data;
    constructor(private http: Http) {
    }

    ngOnInit(): void {
    this.http.get("app/table/data.json")
    .subscribe((data) => {
    setTimeout(() => {
    this.data = data.json();
    }, 1000);
    });
    }
    addRow()
    {
    this.data.push({
    status:''
    })
    }

    deleteRow(index) {
    this.data.splice(index,1);
    }

    public toInt(num: string) {
    return +num;
    }
    public sortByWordLength = (a: any) => {
    return a.city.length;
    }
    }


    Here's my table.module.ts:

    import { NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { FormsModule } from "@angular/forms";
    import { DataTableModule } from "angular2-datatable";
    import { HttpModule } from "@angular/http";

    import { TableComponent } from './table.component';
    import { DataFilterPipe } from './table-filter.pipe';





    @NgModule({
    imports: [
    CommonModule,
    DataTableModule,
    FormsModule,
    HttpModule
    ],
    declarations: [TableComponent, DataFilterPipe],
    exports: [TableComponent]
    })

    export class TableModule { }


    Here's my app.module.ts:

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';

    import { AppComponent } from './app.component';
    import { TableModule } from './table/table.module';


    @NgModule({
    imports: [BrowserModule, TableModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
    })

    export class AppModule { }


    I tried to implement this code in my above app, but it was mess. Please Any help is appreciated, Thanks in advance

    Continue reading...

Compartilhe esta Página