I'm currently delving into AngularJS, but I seem to be stuck on what might be a simple issue.
At the moment, I have some hardcoded JSON files with a few persons in them and no actual backend set up yet. In my form, I aim to display a single person each time. Most of the examples I've come across involve querying for lists or making calls to a REST service with parameters. I'm uncertain how to adapt this approach to my prototype?
The current code successfully retrieves my JSON file and displays the single entity within it. However, once there are multiple entities (let's say 10), I would like to search for a specific one. My next goal is to implement "like" searches and present the results in a modal list... at least, that's the plan.
Here's a snippet of my HTML:
.......
<div class="form-group">
<label for="inputId" class="col-lg-2 control-label">PersonId</label>
<div class="col-lg-6">
<input type="text" class="form-control" id="inputId" ng-model="person.personid">
</div>
<button class="btn btn-mc" ng-click="getPerson()">Search</button>
</div>
My Controller:
.........
.controller('MainCtrl', ['$scope', 'Person', function($scope, Person) {
$scope.person = Person.get();
My Service:
angular.module('myApp.personServices', ['ngResource'])
.factory('Person', ['$resource',
function ($resource) {
return $resource('persons/person.json/:personid', {}, {
get: {method:'GET', isArray:false}
});
}]);
Best regards,