2020-04-04 02:18:47 -04:00
---
page_type: sample
products:
- office-sp
languages:
- javascript
- typescript
extensions:
contentType: samples
technologies:
- SharePoint Framework
platforms:
- AngularJS
createdDate: 8/14/2017 12:00:00 AM
---
# Angular2 Web Part Prototype
2016-11-03 16:10:25 -04:00
## Note to developers
2021-04-26 02:08:59 -04:00
2016-11-03 16:10:25 -04:00
> This web part sample is currently in prototype phase and subject to change.
2017-08-11 10:37:53 -04:00
This sample is not currently supported for use in production environments as unexpected behavior may occur.
2016-11-03 16:10:25 -04:00
It is provided as guidance for building Angular2 web parts in the SharePoint Framework environment.
This sample is a work in progress and it will be updated as advances in stability are made.
## Summary
2021-04-26 02:08:59 -04:00
2016-11-03 16:10:25 -04:00
Sample To Do Web Part built with Angular2. This sample illustrates how you can use Angular2 with the SharePoint Framework.
![Sample of the search web part ](./assets/preview.png )
2021-04-26 02:08:59 -04:00
2021-11-07 01:33:53 -05:00
## Compatibility
![SPFx 0.9.0 ](https://img.shields.io/badge/SPFx-0.9.0-orange.svg )
![Node.js v6 ](https://img.shields.io/badge/Node.js-v6-green.svg )
![Compatible with SharePoint Online ](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg )
![Compatible SharePoint 2019 ](https://img.shields.io/badge/SharePoint%20Server%202019-Compatible-green.svg )
![Compatible with SharePoint 2016 (Feature Pack 2) ](https://img.shields.io/badge/SharePoint%20Server%202016%20(Feature%20Pack%202 )-Compatible-green.svg)
![Local Workbench Compatible ](https://img.shields.io/badge/Local%20Workbench-Compatible-green.svg )
![Hosted Workbench Compatible ](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg )
2016-12-13 04:26:45 -05:00
2016-11-03 16:10:25 -04:00
## Applies to
2020-06-09 03:09:22 -04:00
* [SharePoint Framework Developer Preview ](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview )
* [Office 365 developer tenant ](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-developer-tenant )
2016-11-03 16:10:25 -04:00
## Prerequisites
> Some familiarity of Angular2 architecture.
## Solution
Solution|Author(s)
--------|---------
2021-04-26 02:08:59 -04:00
angular2-prototype | Manish Garg
angular2-prototype | [Daniel Gaeta ](https://github.com/dgaeta )
2016-11-03 16:10:25 -04:00
## Version history
Version|Date|Comments
-------|----|--------
2017-02-03 10:58:54 -05:00
0.3|January 20, 2017| Updates to support RC0
2016-11-03 16:10:25 -04:00
0.2|October 7, 2016|Resolved workarounds to access NgModule and NgZone
0.1|August 14, 2016|Initial release
## Minimal Path to Awesome
- Clone this repository
- In the command line run:
- `npm i`
- `npm i -g gulp`
- `gulp serve`
- Open the workbench
- Test out the web part
## Features
2021-04-26 02:08:59 -04:00
2016-11-03 16:10:25 -04:00
This is a sample client-side web part built on the SharePoint Framework using Angular2 for building the UI component of the web part.
The SharePoint Framework is designed to allow developers to build web parts using the web framework of their choice.
In this prototype we make use of the Angular2 framework. The BaseAngular2WebPart class tries to abstract some of the Angular2 integration.
This way the developer can focus on their web part code and not worry about Angular2 integration.
### Protoype anomalies
2021-04-26 02:08:59 -04:00
2016-11-03 16:10:25 -04:00
Please note, this is an early prototype and we are still trying to learn the best practices of the Angular2 framework.
Angular2 uses TypeScript decorators to annotate classes as Components and Modules.
And also recommends that there be only one NgModule per application.
In this prototype we try to use the decorators dynamically in code.
And each web part instantiates a new NgModule at run time.
Though this is not a best practice, it helps build web parts successfully.
We are trying to find better solutions to this problem. Specially, how to avoid creating a separate NgModule for each web part.
### Adding functionality
2021-04-26 02:08:59 -04:00
2020-04-04 02:18:47 -04:00
To add functionality to this web part prototype the main file to edit is `TodoWebPart.ts` , here there are comments to help you alter the prototype.
2016-11-03 16:10:25 -04:00
### Web part concepts
2021-04-26 02:08:59 -04:00
2016-11-03 16:10:25 -04:00
The web part displays a title, button to add to dos and a button to print the to do items to the console.
This web part illustrates the following concepts on top of the SharePoint Framework:
- Changing a property (the title) of a web part using the PropertyPane
- Manipulating properties in the Angular2 component class and saving to web part’ s property bag
2021-04-26 02:08:59 -04:00
2021-11-01 21:07:49 -04:00
## Help
2021-04-26 02:08:59 -04:00
2021-05-01 21:55:24 -04:00
We do not support samples, but we do use GitHub to track issues and constantly want to improve these samples.
2021-04-26 02:08:59 -04:00
If you encounter any issues while using this sample, [create a new issue ](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=angular2-prototype=@dgaeta&title=angular-todo%20-%20 ).
For questions regarding this sample, [create a new question ](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=angular2-prototype=@dgaeta&title=angular-todo%20-%20 ).
Finally, if you have an idea for improvement, [make a suggestion ](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=angular2-prototype=@dgaeta&title=angular-todo%20-%20 ).
2021-11-07 01:54:14 -05:00
## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
2020-04-04 02:18:47 -04:00
< img src = "https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/angular2-prototype" / >