Skip to content

Commit d843e75

Browse files
author
K.C. Hunter
committed
Adding injectors tutorial
1 parent dcb58d4 commit d843e75

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ AngularJS is an open-source framework in JavaScript. It was created and maintain
1010
It is an MVC (Model-View-Controller) framework so a brief understanding of MVC is suggested, but not required, to use this tutorial.
1111

1212
## Course Videos ##
13-
1. [Compile Part 1](https://www.youtube.com/watch?v=FemQfKf03gY "Compile, Pre, Post")
14-
2. [Compile Part 2](https://www.youtube.com/watch?v=uV_YoyQhrJY "$compile")
15-
3. [Transclude](https://www.youtube.com/watch?v=A0mdSbdE7-E "Transclude")
16-
4. [Config, NgView and NgRoute](https://www.youtube.com/watch?v=ZtqzeYooMw4 "Config, NgView and NgRoute")
17-
5. [RouteParams]( "Route Params")
13+
1. [Custom Provider](https://www.youtube.com/watch?v=FemQfKf03gY "Custom Provider")
14+
2. [Injectors and Invoke](https://www.youtube.com/watch?v=Z8mE2-TWoQ8 "Injectors and Invoke")

src/angularjstutorial.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ app.provider("box", function ()
2424
boxProvider.setColor("#3044b5");
2525
})
2626

27-
.controller("AppCtrl", function ($scope, box)
27+
.controller("AppCtrl", function ($scope, $injector)
2828
{
29-
$scope.color = box.color;
30-
})
29+
$injector.invoke(function (box)
30+
{
31+
$scope.color = box.color;
32+
console.log($scope.color);
33+
});
34+
})
35+

src/resources/js/customProvider.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ app.provider("box", function ()
2020
boxProvider.setColor("#3044b5");
2121
})
2222

23-
.controller("AppCtrl", function ($scope, box)
23+
.controller("AppCtrl", function ($scope, $injector)
2424
{
25-
$scope.color = box.color;
25+
$injector.invoke(function (box)
26+
{
27+
$scope.color = box.color;
28+
console.log($scope.color);
29+
});
2630
})

src/resources/js/injectors.js

Whitespace-only changes.

0 commit comments

Comments
 (0)