Yet Another User
Yet Another User

Reputation: 2905

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>

Upvotes: 3

Views: 182

Answers (1)

Bidhan
Bidhan

Reputation: 10697

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">

Upvotes: 3

Related Questions