I created one service that contains some values and I populate it and imported in two controllers.
Problem is that first controller see all data in it.
But second controller see just empty values.
As service is singleton it should be visible in both.
Am I doing something wrong here?
app.service("MyModel", ['$filter', function ($filter) {
this.items = [];
}]);
app.controller('FirstController', ['$scope', 'MyModel', function ($scope, MyModel) {
var vm = this;
vm.MyModel = MyModel;
}]);
app.controller('SecondController', ['$scope', 'MyModel', function ($scope, MyModel) {
var vm = this;
vm.MyModel = MyModel; // empty (like a new instance)
}]);