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: docs/spfx/web-parts/developer-guide/build-client-side-web-parts-with-angular-1-x.md
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
> **Note:** The SharePoint Framework is currently in preview and is subject to change. SharePoint Framework client-side web parts are not currently supported for use in production environments.
4
4
5
-
Angular is one of the most popular and widely adopted frameworks for building client-side solutions. Thanks to its modularity it can be used for anything ranging from complex multi-view Single Page Applications to smaller components such as web parts. Many organizations have been using Angular for building SharePoint solutions in the past. The following tutorial shows how to use Angular v1.x to build a SharePoint Framework client-side web part and have it styled using [ngOfficeUIFabric](http://ngofficeuifabric.com) - Angular directives for Office UI Fabric. During this tutorial you will build a simple web part that manages to do items.
5
+
If you are using Angular, you can also use this extremely popular framework to build client-side web parts. Thanks to its modularity it can be used for anything ranging from complex multi-view Single Page Applications to smaller components such as web parts. Many organizations have been using Angular for building SharePoint solutions in the past. This article shows how to use Angular v1.x to build a SharePoint Framework client-side web part and have it styled using [ngOfficeUIFabric](http://ngofficeuifabric.com) - Angular directives for Office UI Fabric. During this tutorial you will build a simple web part that manages to do items.
6
6
7
7

8
8
@@ -12,7 +12,7 @@ The source of the working web part is available on GitHub at [https://github.com
12
12
13
13
## Create new project
14
14
15
-
Start by creating a new folder for your project:
15
+
Start by creating a new folder for your project
16
16
17
17
```sh
18
18
md angular-todo
@@ -24,18 +24,18 @@ Navigate to the project folder:
24
24
cd angular-todo
25
25
```
26
26
27
-
In the project folder execute the SharePoint Framework Yeoman generator to scaffold a new SharePoint Framework project:
27
+
In the project folder run the SharePoint Framework Yeoman generator to scaffold a new SharePoint Framework project:
28
28
29
29
```sh
30
30
yo @microsoft/sharepoint
31
31
```
32
32
33
-
When prompted accept the default values:
33
+
When prompted, define values as follows:
34
34
-**angular-todo** as your solution name
35
35
-**Use the current folder** for the ___location to place the files
36
36
-**To do** as your web part name
37
37
-**Simple management of to do tasks** as your web part description
38
-
-**No javascript web framework** as the starting point to build the web part
38
+
-**No JavaScript web framework** as the starting point to build the web part
39
39
40
40


187
187
188
-
In the previous code snippet you implement three types: the **ITodo** interface which represents a to do item in your application, the **IDataService** interface which defines the signature of the data service and the **DataService** class which is responsible for retrieving and manipulating to do items. The data service implements simple methods for adding and modifying to do items. Even though the operations are instantanenous, for consistency each CRUD function returns a promise.
188
+
In the previous code snippet you implement three types: the **ITodo** interface which represents a to do item in your application, the **IDataService** interface which defines the signature of the data service and the **DataService** class which is responsible for retrieving and manipulating to do items. The data service implements simple methods for adding and modifying to do items. Even though the operations are instantaneous, for consistency each CRUD function returns a promise.
189
189
190
-
Note, that in this tutorial to do items are stored in memory. You could however easily extend the solution to store items in a SharePoint List and use the data service to communicate with SharePoint using its REST API.
190
+
In this tutorial to do items are stored in memory. You could however easily extend the solution to store items in a SharePoint List and use the data service to communicate with SharePoint using its REST API.
191
191
192
192
### Implement the controller
193
193
194
-
Next, implement the controller that will facilitate communication between the view and the data service. In the **app** folder create a new file called**HomeController.ts** and paste the following code:
194
+
Next, implement the controller that will facilitate communication between the view and the data service. In the **app** folder create a new file named**HomeController.ts** and paste the following code:
@@ -302,7 +302,7 @@ export default class HomeController {
302
302
303
303

304
304
305
-
You start by loading the previously implemented data service. The controller needs it in order to get the list of items and modify items as requested by the user. Using Angular's dependency injection the service is injected into the controller. The controller implements a number of functions that are exposed to the view model and will be called from the template. Using these functions users will be able to add new items, mark items as finished/to do or delete items.
305
+
You start by loading the previously implemented data service. The controller needs it in order to get the list of items and modify items as requested by the user. Using Angular's dependency injection the service is injected into the controller. The controller implements a number of functions that are exposed to the view model and will be called from the template. Using these functions users will be able to add new items, mark items as finished, to do, or delete items.
306
306
307
307
### Implement the main module
308
308
@@ -328,11 +328,11 @@ todoapp
328
328
329
329
You start by referencing Angular and ngOfficeUIFabric and by loading previously implemented controller and data service. Next, you define the module for your application and load the **officeuifabric.core** and **officeuifabric.components** modules as depedencies for your application. That way you will be able to use ngOfficeUIFabric directives in your template. Finally, you register the controller and data service with your application.
330
330
331
-
This concludes implementing the Angular application behind the web part. In the following steps you will register the Angular application with the web part and make it configurable using web part properties.
331
+
Now you've built an Angular application for your web part. In the following steps you will register the Angular application with the web part and make it configurable using web part properties.
332
332
333
333
## Register Angular application with web part
334
334
335
-
With the Angular application implemented the next step is to reference it in the web part. In the code editor open the **ToDoWebPart.ts** file.
335
+
Next step is to add Angular application to the web part. In the code editor open the **ToDoWebPart.ts** file.
336
336
337
337
Just before the class declaration, add the following lines:
338
338
@@ -343,7 +343,7 @@ import './app/app-module';
343
343
344
344

345
345
346
-
This allows us to load a reference to Angular and your previously implemented application, both of which you need to bootstrap your Angular application.
346
+
This allows us to load a reference to Angular and your application, both of which you need to bootstrap your Angular application.
347
347
348
348
Change the web part's **render** function to:
349
349
@@ -385,7 +385,7 @@ public render(): void {
385
385
386
386

387
387
388
-
You start by assigning the template of your application directly to the web part's DOM element. On the root element you specify the name of the controller that will handle events and data binding in the template. Then, you bootstrap your application using the **todoapp** name you used previously when declaring the main module. Using the **renderedOnce** web part property you ensure that your Angular application is bootstrapped only once. Without it, if you changed one of the web part's properties, the **render** function would be invoked again bootstrapping the Angular application again, which would lead to an error.
388
+
The code first assigns the template of your application directly to the web part's DOM element. On the root element you specify the name of the controller that will handle events and data binding in the template. Then, you bootstrap your application using the **todoapp** name you used previously when declaring the main module. Using the **renderedOnce** web part property you ensure that your Angular application is bootstrapped only once. Without it, if you changed one of the web part's properties, the **render** function would be invoked again bootstrapping the Angular application again, which would lead to an error.
389
389
390
390
You also need to implement CSS styles that you are using the template. In the code editor open the **ToDo.module.scss** file and replace its contents with:
391
391
@@ -406,7 +406,7 @@ You also need to implement CSS styles that you are using the template. In the co
406
406
407
407
## Load newer version of Office UI Fabric
408
408
409
-
Confirm that everything is working as expected by running in the command line:
409
+
Run the following command to confirm that everything is working as expected:
410
410
411
411
```sh
412
412
gulp serve
@@ -416,7 +416,7 @@ In the browser you should see your To do web part showing to do items.
416
416
417
417

418
418
419
-
Looking closely you can notice a bullet sign rendered in front of each item. This has to do with the fact that ngOfficeUIFabric uses a newer version of Office UI Fabric than the version available in the SharePoint workbench. You can fix this issue, by loading a newer version of Office UI Fabric in your web part.
419
+
Looking closely you can notice a bullet sign rendered in front of each item. This is because ngOfficeUIFabric uses a newer version of Office UI Fabric than the version available in the SharePoint workbench. You can fix this issue, by loading a newer version of Office UI Fabric in your web part.
420
420
421
421
If you haven't stopped the **serve** task yet, open the command line and press `CTRL+C` to stop the **gulp serve** task.
422
422
@@ -559,7 +559,7 @@ define([], function() {
559
559
560
560

561
561
562
-
To confirm that everything is working as expected, in the command line run:
562
+
Run the following command to confirm that everything is working as expected:
563
563
564
564
```sh
565
565
gulp serve
@@ -573,7 +573,7 @@ At this point clicking the toggle button doesn't have any effect on your web par
573
573
574
574
### Make the Angular application configurable using web part properties
575
575
576
-
In the previous step you defined a web part property that allows users to choose whether to show completed tasks or not. In this step you will pass the value selected by the user into the Angular application so that it can load items accordingly.
576
+
In the previous step you defined a web part property that allows users to choose whether to show completed tasks or not. Next you will pass the value selected by the user into the Angular application so that it can load items accordingly.
577
577
578
578
#### Broadcast Angular event on web part property change
579
579
@@ -627,7 +627,7 @@ public render(): void {
627
627
}
628
628
```
629
629
630
-
In the above code sample, every time the web part property is changed, it will broadcast an Angular event to which the Angular application will subscribe and handle it accordingly.
630
+
In the above code sample, every time the web part property is changed, it will broadcast an Angular event to which the Angular application will subscribe it. When event is receiverd by the Angular application, it will then handle that accordingly.
631
631
632
632
#### Subscribe to web part property change event in Angular
0 commit comments