Accessing window object in latest Angular 2 vesion

643 kali dilihat
Langsung ke pesan pertama yang belum dibaca

Patrick L.

belum dibaca,
17 Mar 2017, 14.40.4117/03/17
kepadaAngular and AngularJS discussion

The browser window object was removed from latest Angular 2, Does anybody know how to reference a Window object in the latest Angular?

Sander Elias

belum dibaca,
18 Mar 2017, 04.54.4318/03/17
kepadaAngular and AngularJS discussion
Hi Patrick,

I wasn't aware of a special Angular window object, can you provide me some more conext?

Regards
Sander

Patrick L.

belum dibaca,
18 Mar 2017, 23.10.2618/03/17
kepadaAngular and AngularJS discussion
Hi Sander,

The window object represents an open window in a browser in javascript.
example: window.document.getElementById... ..
It does exist in Angular 2.0. but I cannot find it in angular 2.4.

Thanks,
Patrick

Sander Elias

belum dibaca,
20 Mar 2017, 09.30.3320/03/17
kepadaAngular and AngularJS discussion
Hi Patrick

I know what the window object is. I was not aware that there was a special "handler" for inside Angular. The context I wanted for you, is your use-case, so I could help you with whatever it was you needed.

Regards
Sander

Patrick L.

belum dibaca,
21 Mar 2017, 12.00.2621/03/17
kepadaAngular and AngularJS discussion
Thanks, Sander.

I am using angular 2 to access Microsoft signalr API. I need wrap JQuery to setup channel with signalr.

Since angular 2 is type script, ng build cannot be completed although I have install all types for JQuery and Signalr.


Thanks,
Patrick

Sander Elias

belum dibaca,
21 Mar 2017, 12.58.5421/03/17
kepadaAngular and AngularJS discussion
Hi Patrick.

I just looked into signalr. Implementation should be pretty straight forward.  I would create a wrapper service, that hooks up the signalr stuff with observables.
Typescript is a superset of es2015/6/7, so you can just embed the code you need. Perhaps you need to use some explicit any type so here and there to get rid of some typing issues.

Just make sure you are running in a browser, and make sure your code doesn't get run in any other setting.

Regards
Sander

Patrick L.

belum dibaca,
21 Mar 2017, 16.22.0321/03/17
kepadaAngular and AngularJS discussion
Since I found some examples which are using JQuery to communicate with signalr, I want to find how angular 2 uses JQuery. Based on your advice, I will try angular typescript to see if it works.

Thanks in advance.
Patrick

Sander Elias

belum dibaca,
22 Mar 2017, 01.21.0722/03/17
kepadaAngular and AngularJS discussion
Patrick,

wow, I just checked out the signalr dependencies, it asks for a jquery 1.6 to 1.9 that's pretty ancient. If you are building something new, you might consider to a slightly newer technology. However, I'm not exactly current in the >NET environment, so it just might be the right thing to use!

Regards
Sander

Sander Elias

belum dibaca,
23 Mar 2017, 00.19.3323/03/17
kepadaAngular and AngularJS discussion
Oh BTW, 

You don't need anything special in Angular, you can just load the libs you need. (if it's a CLI project, its enough to npm install them, and add them to the config)

Regards
Sander
Balas ke semua
Balas ke penulis
Teruskan
0 pesan baru