declare

Angular 2 Tutorial Part 14 Create an Array Add and Remove Items from it



Sharing buttons:

okay so as you can see I have an array

here and I can add names to it and I can

and remove names from their range so

castas accomplished so um for you that

are using use to c-sharp everything

needs to be declared rather strongly

type language well um in angular

typescript that's not so you see I have

this contact list inside of the

component the to-do list component and

on the initiation of this component I

added two items to this array and

there's no Demming here right no

declaration so this is Justin alright

and there are two items in here Bob and

Dave and then what happens is I have an

NG for and I'm going to iterate through

through the contact list for each

contact and then I have a name right now

then I find a button right here clock -

on that on click event - this delete

contest right so let's talk about adding

person a so hello so what's happening

here is when I click on submit I submit

the form and fire off the Act context so

what it does this uses the push method

of the contact list and add it to this

now you care one very important piece is

the two-way data-binding air binding

whatever's in the textbox to this

variable and that's being passed into

the plant contact

well actually it's not being passed it

it is this is a property of this team

this component and the UI knows about

the property on the delete contact

author were passing in the contact name

yeah right so that the lead is a little

bit more complicated what we're doing is

we're iterating through the contact list

all right and then we find for the

position where the name n is equal to

what is being passed in then we use the

splice method to get rid of it

so there it is very straightforward

so hello

okay thanks