diff --git a/src/client/exercise-01/index.js b/src/client/exercise-01/index.js index b1c8b96..92ca223 100755 --- a/src/client/exercise-01/index.js +++ b/src/client/exercise-01/index.js @@ -17,7 +17,7 @@ appModule.component('layout', { }); appModule.controller('HelloController', - [function () { + ['$timeout', function ($timeout) { this.names = []; this.addName = function () { @@ -30,7 +30,7 @@ appModule.controller('HelloController', // XXXX BAAAD NOT ANGULAR !!!! // DON'T WORK ! // FIX ME ! - setTimeout(() => this.names.shift(), 1000); + $timeout(() => this.names.shift(), 1000); //////////////////////////////////////// }; }] diff --git a/src/client/exercise-02/ng/components/layout.html b/src/client/exercise-02/ng/components/layout.html index 300616f..c415e6f 100755 --- a/src/client/exercise-02/ng/components/layout.html +++ b/src/client/exercise-02/ng/components/layout.html @@ -2,5 +2,6 @@

Exercise 2

Show me Chuck Norris facts :

+
diff --git a/src/client/exercise-02/ng/components/layout.js b/src/client/exercise-02/ng/components/layout.js index 0eee1a4..c347a50 100755 --- a/src/client/exercise-02/ng/components/layout.js +++ b/src/client/exercise-02/ng/components/layout.js @@ -3,9 +3,19 @@ import 'client/exercise-02/ng/services/chuck-norris'; window._app.global_ng_module .component('layout', { templateUrl: 'client/exercise-02/ng/components/layout.html', - controller: ['chuckNorris', function(chuckNorris) { + controller: ['chuckNorris', '$scope', function(chuckNorris, $scope) { + $scope.jokes = []; chuckNorris.fetch3Random().then((res) => { - console.log(res.data.value); + $scope.jokes = res.data.value; }) }] }); + + +window._app.global_ng_module + .component('joke', { + template: '

{{$ctrl.joke.joke}}

', + bindings: { + joke: '=' + } + }); \ No newline at end of file diff --git a/src/client/exercise-02/ng/services/chuck-norris.js b/src/client/exercise-02/ng/services/chuck-norris.js index aa503a9..46d4aa8 100755 --- a/src/client/exercise-02/ng/services/chuck-norris.js +++ b/src/client/exercise-02/ng/services/chuck-norris.js @@ -1,11 +1,11 @@ -const URL = 'http://api.icndb.com/jokes/random/3?exclude=[nerdy,explicit]'; +//const URL = 'http://api.icndb.com/jokes/random/3?exclude=[nerdy,explicit]'; window._app.global_ng_module .service('chuckNorris', ['$http', function($http) { this.fetch3Random = function() { - return $http.get(URL); + return $http.get('http://api.icndb.com/jokes/random/3?exclude=[nerdy,explicit]'); }; }]);