Is there a way to utilize myCtrl instead of myCtrl2 in the given example, passing an argument as a local variable rather than attached to $scope?
The $controller service is capable of performing the necessary operation to encapsulate an existing controller, however, it cannot be accessed directly from the template.
<div ng-app>
<script type="text/ng-template" id="/tpl.html">
value of y: {{y}}
</script>
<div
ng-repeat='x in [1,2,3]'
ng-controller='myCtrl2'
ng-include="'/tpl.html'">
</div>
</div>
function myCtrl($scope, x){
$scope.y = x * 20;
}
function myCtrl2($scope){
$scope.y = $scope.x * 20;
}