Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular not evaluating expression in form action

In my Angular view, I'm using an expression for a form action. Mysteriously, it's not being evaluated and is instead making an HTTP request for http://127.0.0.1:8000/{{ apiUrl }} instead of whatever apiUrl is set to.

apiUrl is being set by the following code: $scope.apiUrl = config.APIURLBase + '/api/upload';, which looks like it should be working fine.

Any ideas?

<h1>Upload new File</h1>
<form action="{{ apiUrl }}" method="post" enctype="multipart/form-data" id="upload-form" class="dropzone" ng-dropzone dropzone="dropzone" dropzone-config="dropzoneConfig">
    <div class="dz-message">
        Drop files here or click to upload
    </div>
    <div class="fallback">
        <input type="file" name="files" multiple />
    </div>
</form>
like image 957
Yet Another User Avatar asked Apr 23 '26 01:04

Yet Another User


1 Answers

I ran across something similar and doing the following fixed it for me.

$scope.api = config.APIURLBase;

And in your form

<form action="{{ api + '/api/upload' }}" method="post" enctype="multipart/form-data" id="upload-form" class="dropzone" ng-dropzone dropzone="dropzone" dropzone-config="dropzoneConfig">
like image 192
Bidhan Avatar answered Apr 25 '26 15:04

Bidhan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!