-1

I'm new in Angular. I have a problem with communicate between controller.

Page layout is like this:

------------------------------------
page header "play" 00:00:00 (TimeController)

------------------------------------

page content <br><br>
ng-view  

(TaskController)<br><br>
ul>li<br>
- "play" link task 1<br>
- "play" link task 2<br>
- "play" link task 3<br>

So I have two controllers TimeController and TaskController. TimeController has a timer in page header.

List of tasks is in rounting view/tasks-list.html


    app.config(['$routeProvider', function($routeProvider) {
        $routeProvider.
            when('/', {
                templateUrl: 'views/tasks-list.html',
                controller: 'TaskController'
            }).

The "play" is a button. When i click on it i need to run a function from TimeController. Also click on "play" in header should run the same function from TimeController.

I dont know how to do this.

2
  • This does not ask a specific question Commented Jul 28, 2014 at 17:30
  • this seems like a duplicate of stackoverflow.com/questions/18482488/… but it's hard to tell for sure. Commented Jul 28, 2014 at 18:39

1 Answer 1

0

Use events. Something like $rootScope.$emit("doSomething"); in the task controller and in the time controller use something like

$rootScope.$on("doSomething", function () {
//event triggered
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.