Reputation: 126
I am trying to create a chat application through angular and php. I have created 2 controllers.
One is for displaying the number of peoples online and other controllers is for sending and recieving messages.
In MainController I can show the person name whom I clicked but in SendMessageController I don't know how to show the same person name.
Please help me, I'm new to angular.
here is working Plunker Link
Upvotes: 0
Views: 40
Reputation: 1597
Use service to share the data between controllers. Inject the service to both controllers.
app.service('userService', function() {
this.userId = '';
this.setUserId = function(id) {
this.userId = id;
};
this.getUserId = function() {
return this.userId;
};
}
Upvotes: 1