javascript - Using AngularJS how to check a PDF file exist in a folder or not? -


I have a list of students for some students, I have to show a link, and click on this link, their progress card Should load (this is a .pdf file). For others, this link should not be shown.

I did this by giving the same student ID to my student card and if this particular student shows this link; Otherwise, do not show links I can do it for only 5 or 6 students. I can not do it for 1000 students

The following is my code:

angular JS code

  & lt; Script & gt; If (response.student_id == 'SD0001') response.student_id == 'SD0002' || Response.student_id == 'SD0004') {$ scope.pdfData = true; $ Dungeon Student pdf file = response.stunt_id + '. PDF'; } And $ scope.pdfData = false; & Lt; / Script & gt;   

HTML code

  & lt; Body id = "ng-app" ng-app & gt; & Lt; Div = ng-switch = "pdf data" & gt; & Lt; div ng-switch-when = "false" & gt; & Lt; / Div & gt; & Lt; Div ng-switch-when = "true" & gt; & Lt; Span class = "font-10" & gt; Download Performance Report & lt; / Span & gt; & Lt; A href = "http://www.example.com/s-pdf/{{StudentPDFFile}}" target = "_ blank" & gt; Click here & lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Body & gt;   

Here I have not specified the controller, this skeleton's functionality is working for me How can I do this for 1000 records?

You can make an HTTP request to determine whether the file exists, or You are on the same domain as the PDF file .

For the given student ID (which appears in your code as response.student_id ):

  If (response. Student_id) {var url = 'http://www.example.com/s-pdf/' + response.student_id + '.pdf'; Var Requests = New XMLHttpRequest (); Request.open ('HEAD', url, false); Sent request (); If (request.status == 200) {$ scope.pdfData = true; $ Dungeon Student pdf file = response.stunt_id + '. PDF'; } And {$ scope.pdfData = false; }} And {$ scope.pdfData = false; }   

'HEAD' is required to ensure the file; You can also use 'GET' , but it does not appear that you need the full file in this situation.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -