Hi Sander,
Thank you for the post and will give it a try, what I was using in my two
controllers was broadcast in my first controller I had this:
$scope.$on('$destroy', function () {
$rootScope.$broadcast("function", 'SEEN');
});
and in my second controller I have:
$scope.$on("function", changeState);
and changeState function would have the state, OPEN and SEEN, something
like this
function changeState(event, to) {
switch(to) {
case states.OPEN:
vm.state = states.OPEN;
break;
case states.SEEN:
vm.state = states.SEEN;
break;
}
}
Even though I was using the above and also tried passing ChangeState as an
argument, it didn't work. How would I fit your method to work with mine
Regards
J
On Monday, 10 August 2015 06:31:37 UTC+1, Sander Elias wrote:
>
> Hi Jay,
>
> You can store your 'viewed' array in an service, and inject that in both
> controllers. Then you can mark a record viewed from both places, and it
> will persist.
> something like this:
>
> angular
> .module('sample',[])
> .controller("one", one)
> .controller("two", two)
> .service("common", common)
>
>
> one.$inject=["common"]
> function one(common) {
> var vm = this;
> vm.selected = common.selected;
> }
>
>
> two.$inject=["common"]
> function two(common) {
> var vm = this;
> vm.selected = common.selected;
> }
>
>
> function common() {
> this.selected = [];
> }
>
>
> the common.selected will be the same, everywhere in your application!
>
> Regards
> Sander
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.