One way:
$scope.$parent.data = [{id:1}, {id:2}]
although that doesn't feel right.
Another would be to create the empty array in the parent, and just modify it instead of replacing it in the child.
Or maybe what you really need is to use a service; it depends on what you are really trying to accomplish.
Defining the service:
var myApp = angular.module('myApp', []);
myApp.factory('tickets', function factory() {
var tickets = [];
function add(ticket){
tickets.push(ticket);
}
function count(){
return tickets.length;
}
return {
add: add,
count: count
};
});
Using the service:
function Parent($scope, tickets) {
$scope.tickets = tickets;
}
function Child($scope, tickets) {
tickets.add({id:1});
tickets.add({id:2});
}
HTML:
<div ng-controller="Parent">
Data length: {{ tickets.count() }}<br>
<div ng-controller="Child">
</div>
</div>
Notice how clean and business-modelly the controllers are, and that you can extend the tickets concept cleanly in one place and access it from anywhere by injecting it into a controller. You can do this without worrying about the hierarchy or relationship between controllers or polluting your environment. On the other hand it might be overkill if your application is extremely simple.