안녕하세요, ng-repeat에서 intrestedid를 가져 오는 중입니다. 이미지를 가져 오기 위해 별도의 API를 보내야하기 때문에 다른 서비스를 호출하고 해당 변수를 동적으로 저장하고 싶습니다.angularjs : 하나의 변수에 값을 반환하는 함수를 저장하는 방법. ng-repeat를 기반으로
내 HTML 내 컨트롤러는 다음과 같이이다이
<div class="" ng-repeat="item in items" >
<div ng-init="MyPic = getMyprofile(item.interestedTo)">
<img src="{{MyPic}}">
</div>
</div>
모습이다.
$scope.getMyprofile = function(IntrstdId){
appServices.profile(IntrstdId, function(response){
$scope.meDetails = response.data;
})
return $scope.meDetails;
}
내 서비스는 다음과 같습니다.
service.profile= function(userId, callback) {
path = serviceUrl + '/profile/'+ userId;
$http({
method: 'GET',
url: path
}).then(function(data) {
callback(data)
}, function(data) {});
}
그러나이 코드의 모든 문제는 정의되지 않았습니다.
실제로 제가 응답 ... 카운터 = increaseCounter (result.id)을 어떤 ID를 전달하고 저장할; –
네, 당신이 원하는대로 서비스에 전달할 수 있습니다. –
아직도 문제를 어디에서 찾을 수 있습니까? –