Skip to content

Commit dcb58d4

Browse files
author
K.C. Hunter
committed
First run for providers branch
1 parent 610c33c commit dcb58d4

18 files changed

Lines changed: 73 additions & 373 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ It is an MVC (Model-View-Controller) framework so a brief understanding of MVC i
1313
1. [Compile Part 1](https://www.youtube.com/watch?v=FemQfKf03gY "Compile, Pre, Post")
1414
2. [Compile Part 2](https://www.youtube.com/watch?v=uV_YoyQhrJY "$compile")
1515
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")
16+
4. [Config, NgView and NgRoute](https://www.youtube.com/watch?v=ZtqzeYooMw4 "Config, NgView and NgRoute")
17+
5. [RouteParams]( "Route Params")

src/angularjstutorial.js

Lines changed: 11 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -2,147 +2,29 @@
22

33
var app = angular.module('MyApp', ['ngRoute'])
44

5-
app.config(function ($routeProvider)
6-
{
7-
$routeProvider
8-
.when('/',
9-
{
10-
templateUrl: "partials/sample.html",
11-
controller: "MainPageCtrl"
12-
})
13-
.when('/pageTwo',
14-
{
15-
template: '<div>This is page <strong>two</strong>!</div>'
16-
})
17-
.when('/calendar/:month/:day/:year',
18-
{
19-
templateUrl: "partials/calendar.html",
20-
controller: "CalendarCtrl"
21-
})
22-
.otherwise(
23-
{
24-
template: '<div><strong>THERE IS NO PAGE HERE!</strong></div>'
25-
})
26-
})
27-
28-
.controller("CalendarCtrl", function ($scope, $routeParams)
29-
{
30-
$scope.model = {
31-
message: "Date: " + $routeParams.month + " / "
32-
+ $routeParams.day + " / "
33-
+ $routeParams.year
34-
}
35-
})
36-
37-
.controller('MainController', function ($scope)
38-
{
39-
$scope.labelName = "New Button";
40-
$scope.newElement = angular.element('<div class="btn btn-default">' +
41-
$scope.labelName + '</div>');
42-
})
43-
44-
.directive('compileDirective', function ($compile)
45-
{
46-
return {
47-
restrict: 'E',
48-
template: '<div>New compile template</div>',
49-
controller: 'MainController',
50-
link: function (scope, elm, attrs)
51-
{
52-
var compileIt = $compile(scope.newElement);
53-
var content = compileIt(scope);
54-
elm.append(content);
55-
}
56-
}
57-
})
58-
59-
.directive('pageDirective', function ()
60-
{
61-
return {
62-
restrict: 'E',
63-
template: '<div>Here is a new button</div>',
64-
controller: 'MainController',
65-
scope: '=',
66-
compile: function (tElem, tAttrs)
67-
{
68-
console.log('compile it. This is the original compiled DOM.');
69-
return {
70-
pre: function preLink (scope, iElement, iAttrs)
71-
{
72-
console.log('pre');
73-
iElement.html('<div class="panel panel-default">Now a panel</div>');
74-
},
75-
post: function postLink (scope, iElement, iAttrs)
76-
{
77-
console.log('post');
78-
iElement.append(scope.newElement);
79-
}
80-
}
81-
}
82-
}
83-
})
84-
85-
.directive('pageDirectiveTwo', function ()
5+
app.provider("box", function ()
866
{
7+
var hex;
878
return {
88-
restrict: 'E',
89-
template: '<div>Here is a second button</div>',
90-
controller: 'MainController',
91-
scope: '=',
92-
compile: function (tElem, tAttrs)
9+
setColor: function (value)
9310
{
94-
console.log('2 compile it. This is the original compiled DOM.');
95-
return {
96-
pre: function preLink (scope, iElement, iAttrs)
97-
{
98-
console.log('2 pre');
99-
},
100-
post: function postLink (scope, iElement, iAttrs)
101-
{
102-
console.log('2 post');
103-
iElement.append(scope.newElement);
104-
}
105-
}
106-
}
107-
}
108-
})
109-
110-
.directive('pageDirectiveThree', function ()
111-
{
112-
return {
113-
restrict: 'E',
114-
template: '<div>Here is a third button</div>',
115-
controller: 'MainController',
116-
scope: '=',
117-
compile: function (tElem, tAttrs)
11+
hex = value
12+
},
13+
$get: function ()
11814
{
119-
console.log('3 compile it. This is the original compiled DOM.');
12015
return {
121-
pre: function preLink (scope, iElement, iAttrs)
122-
{
123-
console.log('3 pre');
124-
},
125-
post: function postLink (scope, iElement, iAttrs)
126-
{
127-
console.log('3 post');
128-
}
16+
color: hex
12917
}
13018
}
13119
}
13220
})
13321

134-
.controller("MainPageCtrl", function ($scope)
22+
.config(function (boxProvider)
13523
{
136-
$scope.mainPageMessage = "I am a new page. Sample.";
24+
boxProvider.setColor("#3044b5");
13725
})
13826

139-
.directive("buttonDirective", function ()
27+
.controller("AppCtrl", function ($scope, box)
14028
{
141-
return {
142-
restrict: 'AE',
143-
transclude: true,
144-
template: '<button class="btn btn-primary" type="button">' +
145-
'Accio Code <data-ng-transclude></data-ng-transclude>' +
146-
'</button>'
147-
}
29+
$scope.color = box.color;
14830
})

src/compile.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/config.html

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
<body>
1414

1515
<div class="mainContainer" data-ng-app="MyApp">
16-
<h1>Features</h1>
16+
<h1>Providers</h1>
1717

18-
<div data-ng-view></div>
18+
<div data-ng-controller="AppCtrl">
19+
<div class="boxContainer" style="background-color: {{color}}">
20+
X
21+
</div>
22+
</div>
1923
</div>
2024

2125

src/partials/calendar.html

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/partials/sample.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/resources/css/angularjstutorial.css

Lines changed: 9 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/resources/css/styles.css

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ html, body {
44
padding: 0;
55
margin: 0; }
66

7-
.panel-success {
8-
color: #d81e05;
9-
background-cikir: #dff0d8;
10-
padding: 14px 8px;
11-
font-size: 1.55em; }
7+
.boxContainer {
8+
width: 100px;
9+
height: 100px;
10+
display: block;
11+
text-align: center;
12+
font-size: 2em;
13+
color: white;
14+
background-color: #000000;
15+
padding: 25px 0 0 0; }

src/resources/css/styles.scss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ html, body {
55
margin: 0;
66
}
77

8-
.panel-success {
9-
color: #d81e05;
10-
background-cikir: #dff0d8;
11-
padding: 14px 8px;
12-
font-size: 1.55em;
13-
}
8+
.boxContainer {
9+
width: 100px;
10+
height: 100px;
11+
display: block;
12+
text-align: center;
13+
font-size: 2em;
14+
color: white;
15+
background-color: #000000;
16+
padding: 25px 0 0 0;
17+
}

0 commit comments

Comments
 (0)