Wikipedia:Reference desk/Archives/Computing/2020 January 21
Computing desk | ||
---|---|---|
< January 20 | << Dec | January | Feb >> | January 22 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
January 21
[edit]Further Angular question
[edit]This StackOverflow answer explained how to use jQuery from inside Angular. I tried it out at work and it worked straight out of the box.
The answer says to write declare var $: any;
. Now I'm sort of a beginner in Angular so my question is, what does the declare
part do? My guess it's the same thing as extern
in C, meaning "this symbol exists, but we're not defining what it does here, it comes from some other place". Is this correct? JIP | Talk 18:28, 21 January 2020 (UTC)
- Declare tells Angular that the variable is declared elsewhere. This is telling Angular that the variable $ is defined somewhere else. It goes a bit further. When compiled, nothing is added to the compiled code to handle the externally declared variable. It is just assumed to exist. Therefore, it is mainly just a hint for the compiler to ignore it and don't throw any warnings or errors if I use it. I wouldn't relate it to C's extern. That is more of a visibility issue, making a variable or function available elsewhere. So, to simplify to the point of being technically incorrect: Angular's define tells the computer to ignore it. C's extern expands scope. 135.84.167.41 (talk) 19:58, 21 January 2020 (UTC)
- So I guess I was somewhat right, that
declare
in Angular means to the compiler "this symbol exists, you don't have to care where it comes from". As I said, I'm a beginner to this Angular thing, I'm more used to statically compiled languages such as C. JIP | Talk 21:50, 21 January 2020 (UTC)- Correct. It tells the compiler to ignore the symbol. 135.84.167.41 (talk) 13:01, 22 January 2020 (UTC)
- So I guess I was somewhat right, that
Forbidden
[edit]If I go to this URL, I get the message: "403 Forbidden" above a line across the top of a white page and "nginx/1.10.3 (Ubuntu)" below. If I go to this URL and click on "View all articles", it goes to the same URL but there is content.— Vchimpanzee • talk • contributions • 21:11, 21 January 2020 (UTC)
- Vchimpanzee, The site may be configured to not allow external links to enter some portions of the site, using HTTP Referer headers. moonythedwarf (Braden N.) 21:18, 21 January 2020 (UTC)
- This is a new development. Is there a way for me to put the section on a list so I don't have to search for that link to "all articles"?— Vchimpanzee • talk • contributions • 21:31, 21 January 2020 (UTC)
- I got a 403 the first time I tried it, but it worked every time after that, including after clearing cookies, closing and re-opening the browser, retrieving with cURL instead of a browser, etc. I haven't tried retrieving through a different IP address. One of my attempts to retrieve with cURL hung in the middle but other attempts worked. It sounds like the site is just a bit flaky. 2601:648:8202:96B0:0:0:0:4FFF (talk) 18:52, 23 January 2020 (UTC)
- That site seems to be doing some pretty horrible things, like depending on a periodic XHR from shopify.com that in turn loads all kinds of tracking beacons into your browser. I would stay away from it in general. I did see the 403 behaviour again after trying a while later though. 2601:648:8202:96B0:0:0:0:4FFF (talk) 20:12, 23 January 2020 (UTC)
- I read the articles there and I have no plans to stop, but for $5 a month you can avoid ads. I don't plan to.— Vchimpanzee • talk • contributions • 19:36, 27 January 2020 (UTC)