Gireesh
Gireesh

Reputation: 101

Angularjs, watching variable value change

I have the AngularJS module declaration as below. Here I have declared value AppModel. I wanted to write code which will be triggered when AppModel.currentTable is changed, How can I watch for this value change ?

angular.module('MIIApp', ['MIIServices']).
value("AppModel",{
    currentTable:"TESTME-h",
    currentUser:null
});

Any help!!!.

Upvotes: 1

Views: 1173

Answers (1)

Robert
Robert

Reputation: 32785

I don’t think you should be doing this. As you can see here a value is intended to be a constant:

value(name, value)

A short hand for configuring services if the $get method is a constant.

In AngularJS a service is a singleton and a value is the most simple of the possible services, when called returns always the same. I don’t know what you need, but could it be you are confusing models with services?

Upvotes: 1

Related Questions