Skip to content

Commit 04b1a7a

Browse files
committed
Update example to use automatic DI
1 parent f4192c9 commit 04b1a7a

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

examples/Todomvc/Controller.purs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ watchLocationPath scope =
102102
_ -> extendScope { statusFilter: { } } scope
103103
in watch expr (return listener) false scope
104104

105-
controller scope location = do
105+
todoctrl scope this location = do
106+
t <- readThis this
106107
path <- getPath location
107108
if S.length path == 0 then setPath "/" location else return ""
108109
watchRemainingCount scope
@@ -126,10 +127,3 @@ controller scope location = do
126127
, doneEditing: doneEditing scope
127128
, removeTodo: removeTodo scope
128129
, revertEditing: revertEditing scope } scope
129-
130-
foreign import todoctrl
131-
" /*@ngInject*/function todoctrl($scope, $location) { \
132-
\ var impl = controller($scope)($location); \
133-
\ return impl.apply(this, []); \
134-
\ } "
135-
:: forall e a. Scope a -> Location -> Eff e Unit

examples/Todomvc/Main.purs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
module Todomvc.Main where
22

33
import Angular.Module (controller, directive, ngmodule')
4+
import Angular.DI (annotate)
45

56
import Todomvc.Controller (todoctrl)
67
import Todomvc.Escape (escape)
78
import Todomvc.Focus (focus)
89

910
main = do
1011
m <- ngmodule' "todomvc" []
11-
controller "TodoCtrl" todoctrl m
12+
controller "TodoCtrl" (annotate todoctrl) m
1213
directive "todoEscape" escape m
1314
directive "todoFocus" focus m

0 commit comments

Comments
 (0)