I have a html file that runs a ng-repeat
and then each item in that ng-repeat will generate a template which also has it's own controller
On the html file I have something like:
<div ng-repeat="item in items">
<div ng-include="'template.html" ng-init="getData(item)"></div>
</div>
And then this template has it's own controller.
The controller has the function getData(item) and looks something like this:
$scope.getData = function(item){
var chapter = item;
}
$scope.myVec = chapter.myVec.length;
template.html looks like:
<div ng-controller = "Controller">
<p>{{myVec}}</p>
</div>
And then I get an error on the console saying "Cannot read property 'length' of undefined"
What am I missing here? Is the controller running before the function that defines the var chapter
?