I have my back-end setup like this.
public function index()
{
$doc = Document::all();
return response()->json([
'Success' => [
'documents' => $doc->toArray()
],
], 200);
// return $doc;
}
In the front-end I have my factory class like this
query:
{
method:'GET',
isArray:false
},
and controller like this.
DocumentsFactory.query(function(documents) {
$scope.documents = documents;
});
Now this setup runs just fine. Here is my console.log
When I try the following in my html.
<div class="col-sm-5">
<select class="form-control m-b-sm" id="procedureId" ng-change="getSelectedProcedure(selectedProcedure.item)" ng-model="selectedProcedure.item" ng-options="document as (document.id + '-' + document.name) for document in documents" required="true"/>
<option value=" ">----------</option>
</select>
</div>
It does not work. Simply shows nothing in selection. Am I doing things the wrong way? What is the best practice for this kind of thing?