You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+70-68
Original file line number
Diff line number
Diff line change
@@ -85,65 +85,65 @@ export default AppComponent;
85
85
A root module is then created, with `AppComponent` imported and registered with `.component('app', AppComponent)`. Further imports for submodules (component and common modules) are made to include all components relevant for the application.
A Component module is the container reference for all reusable components. See above how we import `Components` and inject them into the Root module, this gives us a single place to import all components for the app. These modules we require are decoupled from all other modules and thus can be moved into any other application with ease.
111
+
A Component module is the container reference for all reusable components. See above how we import `ComponentsModule` and inject them into the Root module, this gives us a single place to import all components for the app. These modules we require are decoupled from all other modules and thus can be moved into any other application with ease.
The Common module is the container reference for all application specific components, that we don't want to use in another application. This can be things like layout, navigation and footers. See above how we import `Common` and inject them into the Root module, this gives us a single place to import all common components for the app.
132
+
The Common module is the container reference for all application specific components, that we don't want to use in another application. This can be things like layout, navigation and footers. See above how we import `CommonModule` and inject them into the Root module, this gives us a single place to import all common components for the app.
133
133
134
134
```js
135
135
importangularfrom'angular';
136
-
importNavfrom'./nav';
137
-
importFooterfrom'./footer';
136
+
importNavModulefrom'./nav';
137
+
importFooterModulefrom'./footer';
138
138
139
-
constcommon= angular
139
+
constCommonModule= angular
140
140
.module('app.common', [
141
-
Nav,
142
-
Footer
141
+
NavModule,
142
+
FooterModule
143
143
])
144
144
.name;
145
145
146
-
exportdefaultcommon;
146
+
exportdefaultCommonModule;
147
147
```
148
148
149
149
**[Back to top](#table-of-contents)**
@@ -157,7 +157,7 @@ import angular from 'angular';
Keep it simple and lowercase, use the component name, e.g. `calendar.*.js*`, `calendar-grid.*.js` - with the name of the type of file in the middle. Use `index.js` for the module definition file, so you can import the module by directory name.
182
+
Keep it simple and lowercase, use the component name, e.g. `calendar.*.js*`, `calendar-grid.*.js` - with the name of the type of file in the middle. Use `*.module.js` for the module definition file, as it keeps it verbose and consistent with Angular 2.
183
183
184
184
```
185
-
index.js
185
+
calendar.module.js
186
186
calendar.controller.js
187
187
calendar.component.js
188
188
calendar.service.js
@@ -201,45 +201,47 @@ File structure is extremely important, this describes a scalable and predictable
This example shows a stateful component, that fetches state inside the controller, through a service, and then passes it down into stateless child components. Notice how there are no Directives being used such as `ng-repeat` and friends inside the template. Instead, data and functions are delegated into `<todo-form>` and `<todo-list>` stateless components.
Note how the `<todo-form>` component fetches no state, it simply receives it, mutates an Object via the controller logic associated with it, and passes it back to the parent component through the property bindings. In this example, the `$onChanges` lifecycle hook makes a clone of the initial `this.todo` binding Object and reassigns it, which means the parent data is not affected until we submit the form, alongside one-way data flow new binding syntax `'<'`.
0 commit comments