I am working on angularjs and faced a problem while displaying the details of each record on another page.The list of records are displayed using controller and each record has a link, on click of which i want to pass the id of the selected item to the same controller so that using this id I can display respective data.This is what i have done
<tr ng-repeat="doctor in doct| filter:name" ><td><a href="" ng-click="showid(doctor.contactId)" >></a><td></tr>
this is the code in js file:
app.controller('Mycontroller', function Mycontroller($scope,$http){
$scope.showid=function(idPassedFromNgClick){
var v=idPassedFromNgClick;
console.log(v);
$http.get('scripts/doc.json').success(function(data){
$scope.doct=data;
};
});
});
here i am passing the id in function showid. In console i am able to get the respective id.But i cant use it outside the scope of my function(showid).Plz suggest me a way to get it globally so that i can use it in details page.