Hi,
I have a situation where I get some data from a REST API in a controller, I
render that data using ng-repeat. Then in that loop, I need to run another
controller, pass it data from earlier controller, do some operations on it
and then again run an ng-repeat on it.
When I do it, "Inspect Element" shows value kept in parent controller's
parameter. But the value which is being passed to the nested controller is
actually the variable name.
Source code:
HTML:
<div class="checkbox" ng-repeat="bird in birds">
<table>
<tr>
<td>
<a ng-href="/birds/{{bird.Image}}"
rel="shadowbox"><img ng-src="/birds/{{bird.Image}}" height="200"
width="200"></img></a>
<div ng-controller="imageController" model="{{
bird.AdditionalImages }}">More Images: {{ imageString }}
<div ng-repeat="image in images">
<a ng-href="/birds/{{image}}"
rel="shadowbox[{{ bird.Image }}]">a</a>
</div>
</div>
</td>
<td>
<table>
<tr>
<td>
<b>{{ bird.CommonName }}</b>
</td>
</tr>
<tr>
<td>
Spotted at: {{ bird.SpottedAt }}
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
JavaScript (for nested controller):
anekchidiya.controller('imageController', function($scope, $attrs) {
$scope.imageString = $attrs.model;
console.log("images: " + $scope.imageString);
});
"Inspect Element" shows value of the string, but after "More Images" it
prints "{{ imageString }}" instead of it's value.
Please help.
Regards
Nitin
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.