Cookies in Angular 4 - angularjs

I am trying to create an easy website. I came accross Angular 4 a thought this would be a nice fit for my needs. So I started to mess around and tried to create something.
Now I am trying to set a Cookie. I searched quite a lot, but all I found were some older versions of Angular wich didnt really help me along. They were written in JavaScript, used $cookies and the examples were completly different structured. I am using Typescript.
Can you guys show how to set a cookie in Angular 4 and Typescript?
I am just programming for fun, so please dont expect that much knowlege.
But I am willing to learn. :D
Thank you very much and sorry for my bad english.

You CANNOT set a cookie from the front end. The cookie needs to be sent from the server with a set-cookie header.
And NO! Angular 4 is not known as Angular 2. HOWEVER, Angular 4 drives a lot of similarities from Angular 2 and is built under the same architecture, hence, what works in Angular 2 works for Angular 4, most of the times.

Ok, turns out I'm really stupid. The newest angular-version is 4 but its known as angular 2. So I found my answer really fast.
Sorry for my stupidity.

Related

AngularJS library urls

Good morning.
I would like to know which site contains urls for angular.js and aungula-ui-router.js ? (The question seems not to exist in stackoverflow.com)
Last year i used "https://ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js" but it seems to no longer work.
So what is the official host for angularjs now ?
I know that angularjs is now an old framework but i have to use it at work.
i woul appreciate some help.
Thanks in advance.
I personally prefer to use https://unpkg.com
See,
https://unpkg.com/angular/angular.js
https://unpkg.com/angular/angular.min.js

Migrating angular 1.6 and angular 5

Is it possible to migrate angular1.6 and angular5.
My question:
Without changing angular1.6 code and new angular 5 code run simultaneously?
How to define the code structure for this?
How to grunt these angular1.6 and angular5 code?
Requirement :
Because i need to run application angular1.6 and angular5 independently.
Please give some example to solve this
I do not understand what you mean by running it simultaneously ... please clarify on that. It sure is possible to migrate and you can search for and read many post of people trying to do so. There is even some official advice available #angular.io ... but from my personal experience, I would not do that. Use AngularJS version as a mockup and refactor it freshly into Angular5+ ... it is a tedious job to upgrade from AngularJS 1.6 to Angular5. Can be done, but per my opinion it is not good approach. Learn from what was bad about your AngularJS and try make it better in Angular5, step by step.

Why I decided to start with AngularJS instead of Angular 2

I am clarifying this question after I have been developing SPA for the past 5 months using AngualrJS. In the beginning, I was researching if I should start with Angular 2 instead.
During my research, I came across this article:
https://angular.jsnews.io/why-learning-angular-2-was-excruciating/
https://hackernoon.com/why-learning-angular-2-was-excruciating-d50dc28acc8a
I then realized that I have faced a lot of the issues referenced in that article.
Also, when I started with the offical Angular websites https://angularjs.org/ and https://angular.io/ and followed the recommendation:
I spent several days using the various resources learning Angular 2 based on the above websites and faced a lot of difficulties. I remember I started with this 5 MIN QUICKSTART:
http://a2.hubwiz.com/docs/ts/latest/quickstart.html
Which took me several hours to complete, with several scary error messages in red color.
Later, I started using other resources such as w3schools.com and stackoverflow.com, and I see mostly reference to script tag as follows:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
Which is clear that it was referencing AngularJS. Finally, I realized that learning Angular 2 to start taking advantage of the newly added feature, will cost me a lot of time and effort. Finally, I decided to stay with AngularJS especially I was able to find a solution to each and every business requirement for the complex Forms Application Development I was working on.
Also, I read the other post which is suggested as an answer for my question. What is mentioned there is that Angular 2 is in developer preview:
However, the official websites doesn't mention that. So, the post above is not relevant anymore and I cannot depend on it.
So my recommendation, if you have enough time to spend in learning Angular 2 and deal with the issues that might show-up then of course this is the recommended path, otherwise, best to stay with AngualrJS.
Tarek
you are using angular 1 exactly 1.4.8. it's in the link. Most of the tutorials on the internet for angular 1 that's why everything works ok for you.unless you specify angular 2 in the search you will get angular 1 tutorials that's cause angular 2 is pretty new

How to easily switch to angular 2

So I learn angularJs not long ago, and I'm just getting started to get comfortable with it. But angular 2 is on the way and I have 2 major question:
1) Should I stop learning and working with angular 1 and start learning angular 2 instead?
I know a little about angular 2 and I know almost every thing has changed. So
2) What I know from angular 1 is any good in learning angular 2? Or should I learn angular 2 like it's a whole new framework? Is there any good way or guide to switch from angular 1 to 2?
Thanks in advance for your answers.
I learn angularJs not long ago
Then, this is the perfect time to start learning Angular 2, too. Starting a new language version while you have not already spend a lot of time on another one is a good choice in my opinion. However since Angular 2 is still in RC you should not completely leave learning Angular 1.x and start with Angular 2.
1) Should I stop learning and working with angular 1 and start
learning angular 2 instead?
No, even though the future of Angular framework seems to be Angular 2, this version is still in RC and building large apps using it would be a high risk.Angular 1.x compared to Angular 2 is more stable on this aspect. Angular 2 is constantly evolving, every few weeks there are totally new concepts included.
You should not stop learning Angular 1.x but, you should start learning Angular 2, too.
2) What I know from angular 1 is any good in learning angular 2?
Although there are a lot of changes like between these versions they still have similarities.For instance, in Angular 2 the concept of controllers does not exist, but they use Components. ng-if and ng-for directives from Angular 1.x look like *ngIf and *ngFor in Angular 2. The best resource to compare the two versions is their official website which you can find here here.
Is there any good way or guide to switch from angular 1 to 2?
Although you can still find very useful information about upgrading from Angular 1.x to Angular 2 on their official website
I would suggest that you treat Angular 2 as a completely new framework and start it from zero.Also the knowledge you already have about Angular 1.x will be helpful since there are concepts that have not changed that much. There are plenty of tutorials available online for free that you could use.
My favorite YouTube playlists are:
Angular 2 Start
Angular 2 Basics Course
Build Angular 2 Weather App
Well , This is the major question for all angular2 beginners who knows angular1 ... ,
Just imagine you don't know angularjs1 then Definitely you are more comfortable with angular2 ... The thing is Angular is the future that is the unwritten truth ... Definitely Angular1 is not going to die ...but It may be loose from the competition ... You have to consider following things to choose angular2 ...
Type Script (Great Coding Structure)
Componets (Great Library Support )
Rich Third party library Support
Creator the Giant (Google )
Finally You have to go with the future ... (Angular2)

Specific suggestions on how to prepare for AngularJS 2.0?

I have an AngularJS 1.3 application that will I suppose eventually move to AngularJS 2.0. I've watched the videos from ng-europe and I understand there are many changes. As I expect development to continue with our AngularJS 1.3 code for the next 12 I would like to hear if anyone has any specific suggestions on preparing for 2.0.
My application is simple in that it creates no directives. In particular I would like to hear any tips on how I should go about creating controllers to get ready for them being very different in 2.0. Should I eliminate all references to scope in my controllers. Should I move everything to services?
I hope for some useful suggestions but of course specific ones so this question does not get closed.
Thanks
I think that so little has specifically been announced yet, and there's so much potential for it to change that it's a hard question to answer, e.g. check out this issue for an example of something quite fundamental that's likely to change since the ng-europe announcement.
Within my team we're trying to take the following approach:
Try not to use $scope (controller-as syntax).
Keep your controllers as light as possible by using directives to encapsulate UI functionality and services to deal with data models / API calls.
Use the new syntax for one-way binding where you don't need two-way binding. One-way binding will be the default for Angular 2.0.
Write some unit tests! It'll be much easier to do some significant refactoring if you have some confidence that your code will still work :).
Not only should that help with the move to 2.0 if / when that happens, but it should help your 1.3 apps too!

Resources