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/guidance/build-client-side-web-parts-with-angular-1-x.md
+34-34Lines changed: 34 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
-
title: Build SharePoint Framework client-side web parts with Angular v1.x
2
+
title: Build SharePoint Framework client-side web parts with AngularJS
3
3
ms.date: 09/25/2017
4
4
ms.prod: sharepoint
5
5
---
6
6
7
7
8
-
# Build SharePoint Framework client-side web parts with Angular v1.x
8
+
# Build SharePoint Framework client-side web parts with AngularJS
9
9
10
-
If you are familiar with 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 [Office UI Fabric](http://dev.office.com/fabric). During this tutorial you will build a simple web part that manages to do items.
10
+
If you are familiar with AngularJS, 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 AngularJS for building SharePoint solutions in the past. This article shows how to use AngularJS to build a SharePoint Framework client-side web part and have it styled using [Office UI Fabric](http://dev.office.com/fabric). During this tutorial you will build a simple web part that manages to do items.
11
11
12
-

12
+

13
13
14
14
The source of the working web part is available on GitHub at [https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/angular-todo](https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/angular-todo).
15
15
@@ -48,30 +48,30 @@ Once the scaffolding completes, open your project folder in your code editor. In
48
48
49
49

50
50
51
-
## Add Angular
51
+
## Add AngularJS
52
52
53
-
In this tutorial you will load Angular from CDN. To do that, in the code editor, open the **config/config.json** file and in the **externals** property add the following lines:
53
+
In this tutorial you will load AngularJS from CDN. To do that, in the code editor, open the **config/config.json** file and in the **externals** property add the following lines:

62
+

63
63
64
-
## Add Angular typings for TypeScript
64
+
## Add AngularJS typings for TypeScript
65
65
66
-
Because you will be referencing Angular in your web part's code, you also need Angular typings for TypeScript. To install them run in the command line:
66
+
Because you will be referencing AngularJS in your web part's code, you also need AngularJS typings for TypeScript. To install them run in the command line:
67
67
68
68
```sh
69
69
npm install @types/angular --save-dev
70
70
```
71
71
72
-
## Implement Angular application
72
+
## Implement AngularJS application
73
73
74
-
With all prerequisites in place you can start implementing the sample Angular application. Because it will consist of a few files, create a separate folder for it called **app**.
74
+
With all prerequisites in place you can start implementing the sample AngularJS application. Because it will consist of a few files, create a separate folder for it called **app**.
75
75
76
76

77
77
@@ -307,7 +307,7 @@ export default class HomeController {
307
307
308
308

309
309
310
-
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.
310
+
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 AngularJS'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.
311
311
312
312
### Implement the main module
313
313
@@ -327,13 +327,13 @@ todoapp
327
327
328
328

329
329
330
-
You start by referencing Angular and by loading previously implemented controller and data service. Next, you define the module for your application. Finally, you register the controller and data service with your application.
330
+
You start by referencing AngularJS and by loading previously implemented controller and data service. Next, you define the module for your application. Finally, you register the controller and data service with your application.
331
331
332
-
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
+
Now you've built an AngularJS application for your web part. In the following steps you will register the AngularJS application with the web part and make it configurable using web part properties.
333
333
334
-
## Register Angular application with web part
334
+
## Register AngularJS application with web part
335
335
336
-
Next step is to add Angular application to the web part. In the code editor open the **ToDoWebPart.ts** file.
336
+
Next step is to add AngularJS application to the web part. In the code editor open the **ToDoWebPart.ts** file.
337
337
338
338
Just before the class declaration, add the following lines:
339
339
@@ -344,15 +344,15 @@ import './app/app-module';
344
344
345
345

346
346
347
-
This allows us to load a reference to Angular and your application, both of which you need to bootstrap your Angular application.
347
+
This allows us to load a reference to AngularJS and your application, both of which you need to bootstrap your AngularJS application.

400
400
401
-
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.
401
+
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 AngularJS 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 AngularJS application again, which would lead to an error.
402
402
403
403
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:
404
404
405
405
```css
406
-
.toDoWebPart {
406
+
.toDo {
407
407
.loading {
408
408
margin: 0auto;
409
409
width: 6em;
@@ -674,7 +674,7 @@ Start by adding configuration property in the web part manifest. In the code edi
674
674
675
675
Next, update the signature of the web part properties interface.
676
676
677
-
In the code editor open the **IToDoWebPartProps.ts** file and replace its contents with the following:
677
+
In the code editor open the **ToDoWebPart.ts** file and update the `IToDoWebPartProps` interface to the following:
To fix the missing string references you first need to change the signature of your strings. In the code editor open the **loc/mystrings.d.ts** file and change its contents to:
730
730
731
731
```ts
732
-
declareinterfaceIToDoStrings {
732
+
declareinterfaceIToDoWebPartStrings {
733
733
PropertyPaneDescription:string;
734
-
ViewGroupName:string;
734
+
BasicGroupName:string;
735
735
HideFinishedTasksFieldLabel:string;
736
736
}
737
737
738
-
declaremodule'toDoStrings' {
739
-
const strings:IToDoStrings;
738
+
declaremodule'ToDoWebPartStrings' {
739
+
const strings:IToDoWebPartStrings;
740
740
export=strings;
741
741
}
742
742
```
@@ -767,13 +767,13 @@ In the web part property pane you should see a toggle button for your newly defi
767
767
768
768

769
769
770
-
At this point clicking the toggle button doesn't have any effect on your web part as it hasn't been connected to Angular. You will do that in the next step.
770
+
At this point clicking the toggle button doesn't have any effect on your web part as it hasn't been connected to AngularJS. You will do that in the next step.
771
771
772
-
### Make the Angular application configurable using web part properties
772
+
### Make the AngularJS application configurable using web part properties
773
773
774
-
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.
774
+
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 AngularJS application so that it can load items accordingly.
775
775
776
-
#### Broadcast Angular event on web part property change
776
+
#### Broadcast AngularJS event on web part property change
777
777
778
778
In the code editor open the **ToDoWebPart.ts** file. Right before web part's constructor add the following line:
779
779
@@ -789,7 +789,7 @@ Next, change the web part's **render** function to the following:
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 received by the Angular application, it will then handle that accordingly.
840
+
In the above code sample, every time the web part property is changed, it will broadcast an AngularJS event to which the AngularJS application will subscribe it. When event is received by the AngularJS application, it will then handle that accordingly.
841
841
842
-
#### Subscribe to web part property change event in Angular
842
+
#### Subscribe to web part property change event in AngularJS
843
843
844
844
In the code editor open the **app/HomeController.ts** file. Extend the constructor as follows:
0 commit comments