How does the ng_copy work actually in AngularJS? - angularjs-directive

How does the ng-copy work actually?
I came across the below code and unable to connect the working of ng-copy
<input ng-copy="count = count + 1" ng-init="count=0" value="Copy this text" />
<p>The text has been copied {{count}} times.</p>

Your code works for me in Chrome 70 on a Mac. Here's a stackblitz showing it working.
Are you using a browser that supports the copy event? Note that it's not universally supported.

Related

Whatsapp Click-to-Chat "Couldn't open link" Error Chrome Android/iPhone

I'm using Whatsapp Click-to-chat functionality, without a phone number. It previously worked but with the new Chrome version 76.0.3809.132, both on iOS and Android is not working anymore. On Android, it's showing a Toast with Couldn't open link. Tried contacting Whatsapp Support but no answer as of yet. With the latest update their own documentation example is not working, link to docs. Any suggestions or experiences?
Link example:
<a target="_blank" href="https://wa.me/?text=Villa%20stone%20road%20piece%2015%20meters%20from%20the%20asphalt%20street" title="Share on WhatsApp">
Error picture Imgur: picture
A table with my tested devices and versions on Imgur
If you use https://api.whatsapp.com/send instead of https://wa.me/ you don't need to specify a phone number.
e.g
https://api.whatsapp.com/send?text=Your%20Custom%20Text
It seems that chrome does not accept click to chat without a number specified. Once there's a number in the URL it works just fine.
Unfortunately I did not find a hack to get around it. Neither of this worked:
https://wa.me//?text=Hello%20World
https://wa.me/0/?text=Hello%20World
only if a proper number is specified it will open WhatsApp, but has the recipient already pre selected (the number we provide).
I tested it for a client about 2 weeks ago, when it still worked. So the last update of Chrome (from Aug 26) seems to be the problem...
The best is to use the custom url scheme format. Universal links do not work well with native clients
whatsapp://send/?phone=&text&source&data
It will work without phone number also.
My issue on a recent breaking-change: Universal links stopped working
There was a great blog post about the issue, however it is already outdated and proposes a php specific solution (nevertheless might gives you a good idea, how to think about the problem)
const text = "Hello..."
const phoneNumber = "23400000000000"
Linking.openURL(`whatsapp://send?text=${text}&phone=${phoneNumber}`)
First: Official Whatsapp Sharing Documentation. One of the following URLs is recommended for WEB use...
https://api.whatsapp.com/send?text=YourShareTextHere
https://api.whatsapp.com/send?text=YourShareTextHere&phone=123
And these for MOBILE use...
whatsapp://send?text=YourShareTextHere
whatsapp://send?text=YourShareTextHere&phone=123
If you are interested in watching a project that keeps track of these URLs, then check us out!: https://github.com/bradvin/social-share-urls#whatsapp

Asp.net link to file: in IE strange behaviour

We are working on migrating an older ASP.Net application to the cloud and for that we did several things also updated the application to use a newer .net framework.
Now we face a strange problem, in the application a link is created from data in the database. The html:
<asp:HyperLink ID="linkProjectFolder" CssClass="imageLink" runat="server" ToolTip="Open de folder in de Windows Explorer">
<asp:Image ID="Image1" runat="server" ImageUrl="~/pages/img/openHS.png" />
</asp:HyperLink>
The code behind:
string url = string.Concat(((TextBox)viewINFO.FindControl("txtProjectmapBasePath")).Text, ((TextBox)viewINFO.FindControl("txtProjectmapPath")).Text);
HyperLink hl = (HyperLink)viewINFO.FindControl("linkProjectFolder");
if (hl != null)
{
hl.NavigateUrl = Uri.EscapeUriString(#"file:///" + url);
}
Nothing special and this code has not changed between the old version and the new version. I know that this code does not work in firefox and chrome, but the old version does work in IE11.
Now from the enduser the old version in IE just works, if you click the link a windows explorer window is opened to the file path. For the same end user, from the same workstation with the same browser the new version does not work. When you click the link nothing happens.
Now the strange part, on my development machine, I simulate a network drive by mapping a folder to a drive letter (susbst N: c:\temp\Ndrive) when I try the link I see the same behavior as the end user, just nothing happens. Now if I unmap the drive, start the application and click the link, the link opens in the browser and I get a "page cannot be displayed". If I remap the drive at that moment, go back in the browser and retry the link it works.....
There are of course differences, the .net framework, IIS vs IISExpress vs IIS on azure, but as it is just a simple href I would say it must be client side. Also that the code sometimes works suggests that the urlencoding at least is correct (it does exactly the same as in the old version for the tested url's)
In the database the links are a path to a mapped drive so something like "N:\folder\folder 2\folder & folder\", that is correctly urlencoded and that only works half the time as described above. If I use a link to my C drive "C:\Temp" it never works, if I use "127.0.0.1/C$/Temp/" as link it always works but changing all the links in the database to use an IP address is not really the way we want to go.
After eliminating all the things above I have no clue on what could cause this behavior. Can anybody point me in the right direction ?
Consider revising the asp:HyperLink tag with a nested asp:Image tag with one of these two (2) options:
1) Use an asp:HyperLink tag with ImageUrl property and remove the nested image tag. See this Microsoft Hyperlink.ImageUrl Property page for more information.
2) Use an asp:ImageButton tag with the ImageUrl property. See this SO question titled: how to link imagebutton to url visual developer for more information.
If none of these options resolves your problem, then you may have a file resource access issue rather than an ASP.NET syntax issue.

iOS 9 - Web Form Not Submitting When Photo Selected from Existing Library

I am creating a form in a web app that needs to upload an image file.
This should work whether you take a "new photo" or choose a file from your "existing library".
I am testing the form on iOS 9.1 and I can get it half-working.
If I take a NEW photo, then it works perfectly and advances to the success screen.
If I choose a photo from my existing library, then it does not work. It sort of appears like it's working, but then it just reloads the same page. The data never submits to the backend.
I'm using code I used with iOS 8 and if I recall, it worked properly.
This is what I have:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<form id="defaultForm" method="post" class="form-horizontal" action="/receipt-submit" enctype='multipart/form-data'>
<div class="form-group receiptContainer">
<div class='upload-photo' onclick="$('#receipt').click()">
<image src='/img/camera-icon.png' class='img-responsive' alt='' />Upload Your Receipt</div>
<div id="Ugly">
<input type="file" name="receipt" id="receipt" accept='image/*' />
</div>
</div>
<button type='submit' name="validateBtn" class="upload-photo submit" id="validateBtn">Submit</button>
</form>
I had to get fancy with the styling, which is why you see that div with an id = "ugly".
I would love to get this working with button new and existing images, but nothing I try seems to work.
Any help or ideas is appreciated.
Thanks in advance!
I had a similar issue which has plagued my users since IOS 9 came out. I FINALLY fixed it. Basically, the issue is that Safari Mobile drops the .jpg from the uploaded filename for .jpg media files. Screenshots and current Camera are .pngs, and they get uploaded with an extension, so they work. It's just images you take with the camera and save to the media roll ahead of time that don't have an extension at upload time. Since most server side back end systems check extensions to determine whether the file is an image and should be post-processed, it's most likely that on the server side you are receiving the file, but you are instantly discarding it because it has no extension. Since I couldn't test with a true IOS device against my local dev environment, and ergo, step through the server side code after being submitted by an actual IOS Device (not an emulator), I assumed the same thing, that the input was never getting posted.

Getting value from <file> gives C:\fakepath\filename, even in Linux

I'm getting some very strange behaviour from a file input element in both Chrome and Opera (possibly more, haven't tested).
I have the following HTML:
<div id="profileImgContainer" class="formFile">
<label>Profile Picture</label><div>
<input type="text" id="profileImgText"><input type="button" value="Choose File" id="profileImgButton">
</div>
<input type="file" id="profileImg" name="profileImg">
</div>
And the following jQuery to get the file input's value and put it in the (visible) textbox. The actual file input is hidden.
$(".formFile input[type='file']").live('change', function()
{
$(this).parents(".formFile").find("input[type='text']").val($(this).val());
});
I've made a JSFiddle for you try out. In Firefox, the text box happily takes the filename (don't care about the path) of the file element. In Chrome and Opera, however, when a file is selected the file path in the visible text box changes to C:\fakepath\[filename] where [filename] is the name of the file chosen. This path is obviously fake but what I want to know is why it's changed to it, and whether the file in the hidden upload element will still upload fine. I'm guessing it's a security feature, but I may be wrong.
This is one attempt to mitigate the security issues you get from allowing arbitrary foreign code to run in your browser: The script (which we assume could come from a malicious attacker) does not get to see (and possibly communicate back via AJAX) information about your local files.
Imagine what could happen if a script could just freely set file uploads and submit forms.
This behaviour concerning file upload controls and scripting is mandated by some sort of standard (I believe part of the DOM specification) for this very reason.
I just want to add a new answer for people facing this issue nowadays. Similar to one of the comments, it's better to use the input element itself. For example:
document.getElementById('file-input').files[0].path
This worked for me.
Similar solution for React:
const inpRef = useRef(null)
return (
<input type="file" onChange={() => {
const filePath = inpRef.current.files[0].path
// You can use more properties by looking at the files object
}} />
)

Passing HTML form data in the URL on local machine (file://)

I'm building a small HTML/JS application for primary use on local machine (i.e. everything is accessed via file:// protocol, though maybe in the future it will be hosted on a server within intranet).
I'm trying to make a form with method="get" and action="target.html", in the hope that the browser will put form data in the URL (like, file://<path>/target.html?param1=aaa&param2=bbb). However, it's not happening (target.html opens fine, but no parameters is passed).
What am I doing wrong? Is it possible to use forms over file:// at all? I can always build the url manually (via JS), but being lazy I'd prefer the browser do it for me. ;)
Here is my sample form:
<form name='config' action="test_form.html" method="get" enctype="application/x-www-form-urlencoded">
<input type="text" name="param1">
<input type="text" name="param2">
<input type="submit" value="Go">
</form>
It might be some browser specific restriction. What browser are you using?
I tested this in Firefox 3.6.3 and Internet Explorer 8, and it works just fine.
Ok, that was stupid. The controls of my form are generated dynamically (via JS), and the generation function was setting ids for them, but not names. So, from the form's point of view, there was no parameters at all.
Thanks to Guffa for providing me a nudge in the right direction!