AngularJS 1.6.x Tutorial - 6 - services (and factories)

preview_player
Показать описание
In this video, we create a service (and quickly a factory) to clean up our controller a little bit. We also learn about how to use dependency injection to make the service available inside the controller.

Social media:
Twitter: @johna2
Рекомендации по теме
Комментарии
Автор

Can you tell me why used this instead of scope

priyankamane
Автор

why you do not use $scope instead of "this", there is a difference ?

CalebeMachado
Автор

very cool. can you make a video difference between angularJs old & this one?

MrAdityaPrajapati
Автор

how do you call and use a service in a component which is in another file with 1.6 and es6 ? thx.

blu
Автор

did you ever manage to overcome the cors issue without express, I tried it with browserSync in my gulpfile to add a middleware but it did not worked. see bellow
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE');
res.setHeader('Access-Control-Allow', 'POST, GET, OPTIONS, PUT, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'authorization, x-goog-authuser');
next();
}

I also tried to add the
cors: true, which according to the doc it would be the same if i doit with the middleware, so any idea master?

zakmiltan