I am facing an issue with my ng-repeat and ng-include implementation. I want to include a separate controller inside the view loaded by ng-include, but I am struggling to access the item from ng-repeat in that controller.
Here is what I have tried so far:
How can I access the result
variable inside the SubController
?
<div ng-repeat="result in results">
<div class="box" ng-include="'view/someinclude.html'"></div>
</div>
This is the content of view/someinclude.html:
<div ng-controller="SubController">
...
</div>
And this is how I've defined the SubController in my JavaScript file:
angular.module('SubController', [])
.controller('SubController', ['$scope',
function ($scope) {
//This doesn't work
console.log($scope.result);
}
]);