Skip to content

Commit d43b631

Browse files
committed
Update Step18 with new style and more instructions
1 parent 4e23df1 commit d43b631

File tree

1 file changed

+42
-21
lines changed

1 file changed

+42
-21
lines changed

.docs/angular-meteor/client/content/tutorials/angular1/steps/tutorial.step_18.md

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,30 @@ Next, we want to inject the angular-material module into our Angular application
1818

1919
{{> DiffBox tutorialName="angular-meteor" step="18.1"}}
2020

21-
That's it, now we can use angular-material in our application layout.
21+
Don't forget to remove the `ui.bootstrap` dependency! It's not longer needed!
2222

23-
Angular-material uses declarative syntax, i.e. directives, to utilize Material Design elements in HTML documents.
23+
That's it, now we can use angular-material in our application layout.
2424

25-
First we want to change our `index.html` to make use of the flex grid layout provided by Material Design. So, change your `client/index.html` to look like this:
25+
Our application will have some errors now because we used to use services like `$modal` that belong to bootstrap's core.
26+
27+
So first, let's fix is by using `$mdDialog` instead of `$modal`:
2628

2729
{{> DiffBox tutorialName="angular-meteor" step="18.2"}}
2830

31+
And update the usage in the `AddNewPartyCtrl`:
32+
33+
{{> DiffBox tutorialName="angular-meteor" step="18.3"}}
34+
35+
Great! So now in order get rid of all the bootstrap change we make, we need to remove some and modify some CSS and LESS.
36+
I did that [in this commit](), and this is not part of the tutorial because the CSS is just copy-and-paste piece of code.
37+
Note that most of the change in this commit includes deleting CSS rules that used to override the Bootstrap's design.
38+
39+
Angular-material uses declarative syntax, i.e. directives, to utilize Material Design elements in HTML documents.
40+
41+
First we want to change our `index.html` to make use of the flex grid layout provided by Material Design. So, change your `client/index.html` to look like this:
42+
43+
{{> DiffBox tutorialName="angular-meteor" step="18.4"}}
44+
2945
You can see we use `layout="column"` in the `body` tag, which tells angular-material to lay all inner tags of `body` vertically.
3046

3147
Next, we use the handy `md-toolbar` directive as a wrapper for our app's toolbar.
@@ -43,27 +59,28 @@ element which is actually a separator blank element which is used to fill all th
4359
So, now we have a link to Parties to the left, a span to fill all space, and a login button.
4460
Element layout flex grid is very simple and intuitive in angular-material and you can read all about it [here](https://material.angularjs.org/#/layout/grid).
4561

46-
Next, we need to convert our parties list and party detail views to angular-material.
62+
Next, we need to convert our parties list and party detail views to angular-material.
4763
First, replace the code in your `client/views/parties-list.ng.html` with this code:
4864

49-
{{> DiffBox tutorialName="angular-meteor" step="18.3"}}
65+
{{> DiffBox tutorialName="angular-meteor" step="18.5"}}
5066

5167
What did we do:
5268

5369
* Wrapped everything into the `md-content` tag
5470
* Replaced all the buttons with `md-button` tags
5571
* Wrapped form inputs into `md-input-container` tags which enable the Material Design style labels for inputs
5672
* Added material design Icons
73+
* Use `md-card-content` to display each item in the list
5774

5875
## Material Design Icons
5976

60-
One new thing we also have to add is usage of Material Design icon set. Google provides free icons for Material Design. You can install it by typing:
77+
One new thing we also have to add is usage of Material Design icon set. Google provides free icons for Material Design. You can install it by typing:
6178

6279
meteor add planettraining:material-design-icons
6380

6481
We have to define the `$mdIconProvider` in the `client/lib/app.js`. Insert these lines after the `angular.module` declaration:
6582

66-
{{> DiffBox tutorialName="angular-meteor" step="18.4"}}
83+
{{> DiffBox tutorialName="angular-meteor" step="18.6"}}
6784

6885
You don't have to define all these icon sets.
6986
You just need to define those you need to use.
@@ -72,11 +89,15 @@ You can see in the view code above that to use icons you write:
7289

7390
<md-icon md-svg-icon="content:ic_clear_24px"></md-icon>
7491

75-
in the `md-svg-icon` attribute you list `<iconset>:<icon_name>` in our case `content:ic_clear_24px`.
92+
in the `md-svg-icon` attribute you list `<iconset>:<icon_name>` in our case `content:ic_clear_24px`.
7693

7794
Now, replace the code in the `client/view/party-details.ng.html` with the following code:
7895

79-
{{> DiffBox tutorialName="angular-meteor" step="18.5"}}
96+
{{> DiffBox tutorialName="angular-meteor" step="18.7"}}
97+
98+
And now replace the HTML in the new party modal to use angular-material:
99+
100+
{{> DiffBox tutorialName="angular-meteor" step="18.8"}}
80101

81102
Here, as you can see a specific type of button used by angular-material. We have a link button:
82103

@@ -86,7 +107,7 @@ Angular-Material makes a regular button that points to a link using `ng-href`.
86107

87108
## Custom Angular forms and Accounts-UI Material Design
88109

89-
Next, we need to make our users management pages use Material Design.
110+
Next, we need to make our users management pages use Material Design.
90111

91112
To do that we are going to define our accounts routes manually and use [angular-meteor's auth methods](/api/auth) in our code.
92113

@@ -98,15 +119,15 @@ First we want to remove the Meteor's login button from the toolbar and insert ou
98119

99120
and replace it with:
100121

101-
{{> DiffBox tutorialName="angular-meteor" step="18.6"}}
122+
{{> DiffBox tutorialName="angular-meteor" step="18.9"}}
102123

103124
Now show `Login` and `Sign up` buttons when the user is not logged in, and we show user name and `Logout` button when the user is logged in.
104125

105126
Having created these buttons we need to assign them corresponding routes as referenced in the `ng-href` attributes of our buttons.
106127

107128
Open the `client/routes.js` and insert following routes below the `$stateProvider` line, and above the existing routes:
108129

109-
{{> DiffBox tutorialName="angular-meteor" step="18.7"}}
130+
{{> DiffBox tutorialName="angular-meteor" step="18.10"}}
110131

111132
* controllerAs -
112133
First thing of note here is that we're using `controllerAs` parameter in the route definition. This gives an alias to `$scope` and many other benefits. For detailed information, read [this article](http://toddmotto.com/digging-into-angulars-controller-as-syntax/). You will see later how we use it.
@@ -119,7 +140,7 @@ So, let's go ahead and create them. Create a subfolder `users` in the `client/`
119140

120141
Create a file `client/users/controllers/login.js`. Paste the following code:
121142

122-
{{> DiffBox tutorialName="angular-meteor" step="18.8"}}
143+
{{> DiffBox tutorialName="angular-meteor" step="18.11"}}
123144

124145
Now, instead of using $scope, we're using *controller as* syntax, so we declare a variable `vm` and assign `this` to it.
125146
From now on, each `$scope.` variable or method will be declared as `vm.` variable or method.
@@ -137,7 +158,7 @@ It returns a promise, and on success we redirect the user `parties` state, or as
137158

138159
Now create a view file with login form in `client/users/views` folder and name it `login.ng.html`. Paste the following code:
139160

140-
{{> DiffBox tutorialName="angular-meteor" step="18.9"}}
161+
{{> DiffBox tutorialName="angular-meteor" step="18.12"}}
141162

142163
In our router file, we declared the login route controller to be `LoginCtrl` and a `controllerAs` parameter to be `lc`.
143164

@@ -146,21 +167,21 @@ So to address all variables/objects/methods of our controller, we prefix them wi
146167

147168
In our view. You can see in the view that we use `lc.error`, `lc.credentials`, and `lc.login()`.
148169

149-
The procedure is the same for the `register` and `resetpw` routes, so now you create `client/users/controllers/register.js` and paste following code into it:
170+
The procedure is the same for the `register` and `resetpw` routes, so now you create `client/users/controllers/register.js` and paste following code into it:
171+
172+
{{> DiffBox tutorialName="angular-meteor" step="18.13"}}
150173

151-
{{> DiffBox tutorialName="angular-meteor" step="18.10"}}
152-
153174
Create a file `client/users/views/register.ng.html` and paste the following code into it:
154175

155-
{{> DiffBox tutorialName="angular-meteor" step="18.11"}}
176+
{{> DiffBox tutorialName="angular-meteor" step="18.14"}}
156177

157-
Create a file `client/users/controllers/reset.js` and paste the following code into it:
178+
Create a file `client/users/controllers/reset.js` and paste the following code into it:
158179

159-
{{> DiffBox tutorialName="angular-meteor" step="18.12"}}
180+
{{> DiffBox tutorialName="angular-meteor" step="18.15"}}
160181

161182
And, finally, create a corresponding view `client/users/views/reset-password.ng.html` and paste the following into it:
162183

163-
{{> DiffBox tutorialName="angular-meteor" step="18.13"}}
184+
{{> DiffBox tutorialName="angular-meteor" step="18.16"}}
164185

165186
# Summary
166187

0 commit comments

Comments
 (0)