JSFiddle - React, Tailwind, and code Playground
by Xesued
HTML
<h1>Controller Scope</h1>
<div ng-controller="firstCtrl">
<ul>
<li ng-repeat="(id, info) in usersModels.online">
{{id}} - {{info.checked}}
</li>
</ul>
</div>
JavaScript
angular.module('myApp', []).
controller('firstCtrl', ["$scope", function ($scope) {
$scope.users = [{id:1,name:"Joe"},{id:2,name:"Sue"}];
$scope.usersModels = {};
$scope.usersModels.online = {};
angular.forEach($scope.users, function (user) {
this.usersModels.online[user.id] = {};
this.usersModels.online[user.id].checked = 'checked';
this.$watch('usersModels.online[user.id]', function(val) {
console.log(val);
});
}, $scope);
}]);
angular.bootstrap(document, ['myApp']);