I'm looking to streamline my controller by setting a variable from outside the controller to populate my checkbox list. Can this be done?
Check out my current code snippet here: http://jsfiddle.net/ilmansg/Lx37kr3e/1/
VIEW HTML
<div ng-controller="AdminEventsCtrl">
<h1>Array 1</h1>
<ul>
<li ng-repeat="item in array1">
<input type="checkbox" ng-model="formData.value1[item.value]" value="{{item.value}}" />
{{item.text}}
</li>
</ul>
<h1>Array 2</h1>
<script>
array2 = [{
text: 'Option 1',
value: 'opt1'
}, {
text: 'Option 2',
value: 'opt2'
}, {
text: 'Option 3',
value: 'opt3'
}, {
text: 'Option 4',
value: 'opt4'
}];
</script>
<ul>
<li ng-repeat="item in array2">
<input type="checkbox" ng-model="formData.value1[item.value]" value="{{item.value}}" />
{{item.text}}
</li>
</ul>
<pre>Array1= {{array1}}</pre>
<pre>Array2= {{array2}}</pre>
</div>
SCRIPT JS
var myApp = angular.module('myApp', []);
function AdminEventsCtrl($scope) {
$scope.formData = {};
$scope.array1 = [{
text: 'Option 1',
value: 'opt1'
}, {
text: 'Option 2',
value: 'opt2'
}, {
text: 'Option 3',
value: 'opt3'
}, {
text: 'Option 4',
value: 'opt4'
}];
}