Laura Kerr
Laura Kerr

Reputation: 1

how can i display a result from a server javascript function to a html page using angular

This is a form that will go to the javascript page and will upload the photo to the server

  <div class="col-sm-5" style="border-right: 1px solid #ccc">
               <div class="subStyle" ng-show="showDiv1">
                   <form id        =  "uploadForm"
                      enctype   =  "multipart/form-data"
                      action    =  "/api/photo"
                      method    =  "post">

                      <input type="file" name="userPhoto" /> 
                      <input type="submit" value="Upload Image" name="submit">
                   </form>
                </div>
                </div>

This is the JavaScript function

 function confirmUploaded() {
  res.end("File was successfully uploaded -- " + outText);

}

How would i call this function from the JavaScript file to the HTML page

Upvotes: 0

Views: 61

Answers (1)

Shankar Shastri
Shankar Shastri

Reputation: 1154

res.end is not a client side, It is a server side code and need to be send from the server end(NodeJS).

Make use of $http.success in angular and then on success attach the result to a particular div or header tags and use css for formatting.

Upvotes: 1

Related Questions