I want to inject the same variables with different values multiples times to the same controller. This is what I tried. What is a way to get different values in each call?
<body ng-app="myApp">
<div ng-controller="myCtrl" ng-init="test='helloworld';test1='helloworld2'">
</div>
<div ng-controller="myCtrl" ng-init="test='helloworld3';test1='helloworld4'">
</div>
<div ng-controller="myCtrl" ng-init="test='helloworld5';test1='helloworld6'">
</div>
<body>
var app = angular.module("myApp", []);
app.controller("myCtrl", ["$scope",function($scope) {
console.log($scope.test);
console.log($scope.test1);
}]);
Found a dirty fix. Thanks all for your inputs.
var app = angular.module("myApp", []);
app.controller("myCtrl", ["$scope", '$timeout',function($scope, $timeout) {
$timeout(function(){
console.log($scope.test);
console.log($scope.test1);
}, 1);
}]);