I want to incorporate a search form into my application that sends the form result to the specified link. I am retrieving artist names from the musicbrainz JSON database using the following request: "NAME OF AN ARTIST"%20e*&fmt=json
The "NAME OF AN ARTIST" is the input that I want to submit through the form. I am new to angular and struggling to understand how to achieve this despite researching online.
Below is the search form:
<form ng-submit="search()" name="nomartiste">
<label>Search:
<input type="text" ng-model="nom"/>
<input type="submit" value="Search"></input>
</label>
</form>
Here is the JavaScript code:
function Artist($scope)
{
$scope.nom = 'Muse';
$scope.search = function()
{
var url = "http://search.musicbrainz.org/ws/2/artist/?query=" + $scope.nom + "%20e*&fmt=json";
$http.get(url)
.then(function(response)
{
$scope.artistNames = response.data;
console.log($scope.artistNames);
})
}
}
The request results, based on the input from $scope.nom
in the form, should be displayed. However, no data is showing up in the console log, not even the Json tree.