Thứ Bảy, 4 tháng 11, 2017

Waching daily Nov 4 2017

In this video I'll explain the basics of how to use the Angular HTTP.get method.

Making an http.get request in angular is pretty simple to set up.

Before we jump into the code, let's take a look at this example page.

So after the page loads, we see some data in the page, and this data is fetched asynchronously,

and then injected into the page.

Let's inspect it and take a look at the network tag.

Now I'm going to refresh the page, and look down here and I see this request, and here's

the response we're getting back.

So notice how the data from the response matches the data in our page.

The first item is London, price 1200, Paris price 2250, Miami price 1100, and so forth.

So obviously this data in the page matches the data that we're getting back here.

So just to illustrate that the data in the page is being fetched asynchronously, and

then being injected into the page.

So let's see how this all works.

So here are my components.

In the Init method, the ngOnInit method, I set a timeout, and I'm just doing that so

that you can see when the page loads that something's happening asynchronously.

Otherwise it happens in about a half a second and it all flies by too quick, so I just wait

a second and then I call the load packages method.

It's just a function that I wrote.

But the load packages method is really where things happen.

So here, we're referencing the http service, and we're calling the get method on that service.

So this url right here is just a free JSON service that I'm using that creates dummy

data.

In fact, if I go to a browser, and I paste that url, this is the data that I get back,

and you can see it matches the data in our page.

This is the data that we got back earlier.

London price 1200, Paris price 2250, and Miami price 1100, and so forth.

So this is the data that actually shows up here.

It's just if I paste this url, I get the actual raw data.

But I say all that just to point out that this right here makes an asynchronous http.get

request and it's just some dummy data that I've set up.

And next, I'm going to convert the result of that get request.

There's some JSON, and then I'm going to subscribe to that JSON.

I don't want to get into this too much, but this is a feature of rxjs, which allows you

to subscribe to a data stream.

But the point here is just to understand the syntax: that we make the get request, we use

the map method to convert it to jason and we subscribe to that jason.

And when we subscribe to that jason, this is a callback that we're passing to the subscribe

method.

And in that callback we're getting some data and I'm saying this.destinations equals data.

So I'm saying that the destinations property on this component, which is an array, is equal

to the data that I get back.

So let's look in our template and see how that winds up in the view.

So here I've got an unordered list, and for the unordered list I've got one li but for

the li i'm using an ngfor and I'm saying let destination of destinations, this destinations

property right here corresponds to this destinations property here in our component.

So we're saying in the template, for every element in the destinations array, call it

destination and then populate this template, and we have the name destination name, destination

duration, and the destination price.

And these, this template right here, corresponds to what you see here: the duration ten days,

the price 1200, so that's how that gets here.

So the main thing to keep in mind is the syntax for making an http request.

We first reference this.http and that's because we're importing the http servers and we're

setting http to be a property of 1r component, and we're referencing the http service and

its get method.

We're making the get request and then we're mapping the result of that request to some

JSON, and then we're subscribing to that JSON data so that when it comes through -- this

is a technique for handling asynchronous activities in javascript -- so we're saying when this

data comes through, we want to get it and assign it to this.destinations.

And this.destinations is an array, and that array is set up in a template and we're looping

through it and saying for every destination destinations, populate the template with that

destination.

And we wind up getting a page that makes an asynchronous request and loads the data that

it gets from that request into the page.

If you found this video helpful, you can subscribe to my channel by clicking the red "Subscribe"

button right under the video.

You can also take a look at my blog, where there are many articles and tutorials about

web development.

Thanks very much for watching.

For more infomation >> Angular http.get basics - Kevin Chisholm Video - Duration: 5:24.

-------------------------------------------

WALMART SPONSOR US VIDEO - Duration: 1:58.

WOW...

WHAT A GREAT GUY!!!

For more infomation >> WALMART SPONSOR US VIDEO - Duration: 1:58.

-------------------------------------------

Troll Face Quest Video Games Halloween - Duration: 3:59.

Troll Face

For more infomation >> Troll Face Quest Video Games Halloween - Duration: 3:59.

-------------------------------------------

Readathon Recap // Bout of Books #20 (+ First Booktube Video!) - Duration: 6:34.

hello my name is Julia and I am attempting a YouTube video so we will

see how this goes I thought for my first official YouTube video I would talk

about my first read-a-thon that I did and I did bout of books specifically

bout of books 20 and I did it mostly through Twitter and Instagram and on

Instagram I do have a book stir gram handle which is the curly bookworm as

you can see I have curly hair so curly bookworm on Instagram well powder books

is really casual so I I thought I would because my first read on I tried a

read-a-thon ages ago and I failed miserably because it had ten books yet

to pick and I work full time and I just didn't have time to do it so bout of

books is so much more casual you pick your own goal your own pace you can

change your goal halfway through review on it's very very casual which is

exactly what I needed yeah and so my goal was I just want to

read fifty pages a day I usually read like thirty pages a day maybe because I

usually read on the train and I hit it so that was that was great

I actually read in total 1078 pages which is way way more than I expected to

read and I also participated on one of the Twitter chats there's two Twitter

chats I did one of them which was really fun and I did do a couple of the the

social media challenges I did the books vine rainbow I did a couple of the other

ones going into Wouter books I had two books that I'd already begun just barely

like I think I was 20-something pages into both of them but they are Night

Circus by Erin Morgenstern and also iron cast by iron cast by destiny Soria there

we go and if I ever figure out how to put and

I also picked two other books for my TBR although I didn't actually expect to

finish them and those were something in between bye

sedale accrues and the last boy and girl in the world by Siobhan Vivian I

finished iron cast and I also finished something in between by Melissa de la

Cruz iron cast I've been meaning to read for a while the author was at the Boston

teen author fest a couple of years ago 2015 maybe and her

book always looked really interesting to me and he's never picked it up so I went

to the library recently and I saw it there I thought now would be a great

time to pick it up and read it I enjoyed iron cast I gave it 3 out of 5

stars I really liked no spoilers so don't worry I really liked that it had a

really good pot I really liked the the characters and then I thought there was

a good diversity of characters I really liked the location and the time setting

it was Boston in like 1919 so right on the cusp of the twins which I love the

20s I had some trouble at the point of view I thought it switched kind of

funcly' and the two main characters are both girls and I had a really hard time

telling apart because their narrative voices were so similar so anytime the

author said something about their physical appearance are one of their

quirks that I could tell who it was but when they switched back before they had

a hard time switching quickly in my mind so that was a big detractor for me but I

thought it was a worthwhile read and again I really liked the plot and the

idea of the book yeah so the other book I finished was something in between but

Melissa de la Cruz it's about a girl who believes she's a legal immigrant to the

United States and finds that when she applies to college that she's not and

she's been undocumented her whole life and so is her whole family and she was

completely unaware of this and so it's her going through what that means for

her and how is she gonna go to college and of course there's a romance plot

line as well I enjoyed this and I did think it was interesting that it picked

it up now with all that's been going on politically I also gave it three stars I

think I did I did give it three stars the writing wasn't really

my favorite style but I thought it was important enough that it was worth

finishing I did enjoy the main character's name is Jasmine I thought

she was a really strong character she's really smart really motivated but I

didn't love every aspect of the book specifically the romantic flat light I

was not a big fan but that's okay it was worthwhile reading it I would suggest

picking it up and actually I there's other books by

Melissa de la Cruz that I want to read now after I read this two books that I

did not finish are the Night Circus it's not cuz they don't like it I really like

it actually so far I'm 300 something pages and it's basically a love story

and I think it's really good and I love the whole setting of the black and white

circus it's so so cool I've kind of been taking my my time within now that bout

of books is over I'm not in a rush to finish it and then the other one which I

started on the last day just because I really wanted to say I had started at

least all for the books that were my TBR was um the last boy and girl in the

world by Siobhan Vivian and I love this cover I think this is so so pretty it

reminds me of a what's that called uh the paper would people tear paper and

make artwork out that that's what it reminds me of it I think it's really

beautiful this is about a town that is gonna be flooded it's gonna go

underwater and it's once again another romance Keeley has this big crush on

Jesse and so if she decides to kind of go out with a bag and try and get his

attention as they you know their whole lives are washed away

I suppose so far it's a quick read and again I really love the cover um yeah so

that was my house my bout of books this is maybe my first youtube video we'll

see what happens after I edit it why

Không có nhận xét nào:

Đăng nhận xét