File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
class CategoriesModel {
2
- constructor ( $q ) {
2
+ constructor ( $q , $rootScope ) {
3
3
'ngInject' ;
4
4
5
5
this . $q = $q ;
6
+ this . $rootScope = $rootScope ;
6
7
this . currentCategory = null ;
7
8
this . categories = [
8
9
{ "id" : 0 , "name" : "Development" } ,
@@ -18,6 +19,7 @@ class CategoriesModel {
18
19
19
20
setCurrentCategory ( category ) {
20
21
this . currentCategory = category ;
22
+ this . $rootScope . $broadcast ( 'onCurrentCategoryUpdated' ) ;
21
23
}
22
24
23
25
getCurrentCategory ( ) {
Original file line number Diff line number Diff line change 1
1
class BookmarksController {
2
- constructor ( CategoriesModel , BookmarksModel ) {
2
+ constructor ( $scope , CategoriesModel , BookmarksModel ) {
3
3
'ngInject' ;
4
4
5
+ this . $scope = $scope ;
5
6
this . CategoriesModel = CategoriesModel ;
6
7
this . BookmarksModel = BookmarksModel ;
7
8
}
@@ -12,6 +13,7 @@ class BookmarksController {
12
13
this . bookmarks = bookmarks ;
13
14
} ) ;
14
15
16
+ this . $scope . $on ( 'onCurrentCategoryUpdated' , this . reset . bind ( this ) ) ;
15
17
this . getCurrentCategory = this . CategoriesModel . getCurrentCategory . bind ( this . CategoriesModel ) ;
16
18
this . deleteBookmark = this . BookmarksModel . deleteBookmark ;
17
19
}
You can’t perform that action at this time.
0 commit comments