SlideShare a Scribd company logo
Practical TypeScript with AngularJS
Typescript 102
Bob Goodearl
RGood Software
www.RGoodSoftware.com
Bob German
BlueMetal
www.bluemetal.com
Boston Code Camp 25 - Thanks to our Sponsors!
• Platinum
• Gold
• Silver
• Bronze
• In-Kind Donations
Bob German
Bob Goodearl
• Blog: http://bob1german.com/
• Linked In:
https://www.linkedin.com/in/bgerman
• Twitter: @Bob1German
• Email: bobg@bluemetal.com
• Website: http://www.rgoodsoftware.com
• Linked In:
https://www.linkedin.com/in/bgoodearl
• Email: bgoodearl@rgoodsoftware.com
Presenters
Agenda
• TypeScript Widget
• Modules
• Controllers
• Services
• TypeScript Definitions for REST Calls
• TypeScript SPA with ASP.NET MVC
• Anatomy of an AngularJS/MVC/TypeScript web app
Setup steps:
• Install VS Code
• Install Node (https://nodejs.org/en/download)
• npm install –g typescript
• Ensure no old versions of tsc are on your path; VS
adds:
C:Program Files (x86)Microsoft
SDKsTypeScript1.0
• In VS Code create tsconfig.json in the root of your
folder
{
"compilerOptions": {
"target": "es5“,
"sourceMap": true
}
}
• Use Ctrl+Shift+B to build – first time click the
error to define a default task runner
Edit task runner and un-comment the 2nd
example in the default
• npm install –g http-server
(In a command prompt, run http-server and
browse to http://localhost:8080/)
VS Code Environment
Setup steps:
• Install Visual Studio
• For VS2012 or 2013, install TypeScript extension
• Build and debug the usual way
• Consider WebEssentials for side by side TypeScript
and JavaScript view
(does not work in VS2015)
Visual Studio Environment
• Commonly used on the Internet called ”Web
Widgets”, ”Plugins”, ”Embeds”, etc.
• It’s just a clever piece of HTML and
Javascript that acts like a web part
• Often deployed by authors/end users
seperately from the hosting application
• Very handy in SharePoint and other content
management systems
What is a widget?
What makes a good widget?
1
ISOLATED – so they won’t interfere with other
widgets or the rest of the page
Can you run multiple copies of the widget on a
page?
2
EFFICIENT – so they load quickly Does the page get noticeably slower as you add
widgets?
3
SELF-CONTAINED – so they’re easy to reuse Does the widget work without special page elements
such as element ID’s, scripts, and CSS references?
4
MODERN – so they’re easier to write and maintain Is the widget written in a modern JavaScript
framework such as AngularJS or Knockout?
JavaScript Library allows you to run multiple Angular* apps on a page …
<div> <!-- ng-app=“HelloApp” -->
<div ng-controller="main as vm">
<h1>Hello{{vm.space()}}{{vm.name}}!</h1>
Who should I say hello to?
<input type="text" ng-model="vm.name" />
</div>
<!-- Widget Wrangler loads scripts and boots the app -->
<script type="text/javascript" src="pnp-ww.js“
ww-appName="HelloApp“
ww-appType="Angular“
ww-appScripts='[{"src": “~/angular.min.js", "priority":0},
{"src": “~/script.js", "priority":1}]'>
</script>
</div>
Widget Wrangler
* Also works with any JavaScript framework – or none at all
demo
AngularJS Widget in TypeScript
• Model
• Controller
• Service
• TypeScript Definitions for REST services
Typescript 102   angular and type script
demo
AngularJS Widget in TypeScript
• Model
• Controller
• Service
• TypeScript Definitions for REST services
Anatomy of an
AngularJS/MVC/TypeScript web app
• Why Integrate AngularJS and MVC?
• Why add TypeScript?
• Open source code you can experiment with
• http://bit.ly/MvcNgTsDemo
• Lessons Learned
demo
MVC5NgTsDemo
Generating TypeScript definitions
• Experiments with TypeLite
http://bit.ly/1WW9ckN
• Other options (not yet explored)
• Typewriter extension for Visual Studio
http://bit.ly/VsX-Typewriter
Resources
Session Materials
and Code Samples
• http://bit.ly/bcc25ts102
TypeScript Playground
• http://bit.ly/TSPlayground
TS Def’ns from JSON
• http://json2ts.com/
An Insight company
Thank you.
Bob Goodearl
Bob German

More Related Content

PPTX
Modern SharePoint Development using Visual Studio Code
PDF
Introduction to xamarin
PDF
Xamarin.Forms
PDF
Xamarin microsoft graph
PDF
Cross Platform Mobile Development
PDF
Azure mobile services
PDF
.Net Dev Summit 2020 - What's new and next for Xamarin developers
PDF
Xamarin DevOps
Modern SharePoint Development using Visual Studio Code
Introduction to xamarin
Xamarin.Forms
Xamarin microsoft graph
Cross Platform Mobile Development
Azure mobile services
.Net Dev Summit 2020 - What's new and next for Xamarin developers
Xamarin DevOps

What's hot (20)

DOCX
Ionic
PDF
Building Desktop RIAs with PHP, HTML & Javascript in AIR
PDF
Building Mobile Cross-Platform Apps with the Cloud and Push Notifications
PDF
Introduction to Mobile Development with Xamarin -DotNet Westide
PPT
Native App Development for iOS, Android, and Windows with Visual Studio
PPTX
Hybrid Mobile App Development - Xamarin
PPTX
Introduction to xamarin
PDF
What's New in Xamarin? - Santo Domingo
PDF
Cross platform mobile web apps
PPTX
Ionic framework
PDF
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
PDF
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
PDF
Native i os, android, and windows development in c# with xamarin 4
PDF
Visual Studio Toolbox - Introduction To Xamarin.Forms
PDF
Introduction to CocosSharp
PPTX
Xamarin Forms
PDF
Hybrid Apps with Angular & Ionic Framework
PPTX
Highlights from the Xamarin Evolve 2016 conference
PPT
Js frameworks
Ionic
Building Desktop RIAs with PHP, HTML & Javascript in AIR
Building Mobile Cross-Platform Apps with the Cloud and Push Notifications
Introduction to Mobile Development with Xamarin -DotNet Westide
Native App Development for iOS, Android, and Windows with Visual Studio
Hybrid Mobile App Development - Xamarin
Introduction to xamarin
What's New in Xamarin? - Santo Domingo
Cross platform mobile web apps
Ionic framework
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Native i os, android, and windows development in c# with xamarin 4
Visual Studio Toolbox - Introduction To Xamarin.Forms
Introduction to CocosSharp
Xamarin Forms
Hybrid Apps with Angular & Ionic Framework
Highlights from the Xamarin Evolve 2016 conference
Js frameworks
Ad

Viewers also liked (20)

PPTX
Typescript 101 introduction
PDF
Why learn french
PPTX
Intro to behavioural law & economics
PPTX
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
PPTX
From Solutions to Apps - Moving to SP2013
PPTX
Introduction to AngularJS with the Microsoft Graph
PPTX
Building Flexible SharePoint Solutions with AngularJS
PPTX
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
PPTX
Leveraging User Profiles and MySites
PPTX
Collab365 Global Summit Slides
PPTX
Session Slides from DEVintersection Europe
PPTX
European SharePoint Conference - TH3
PPTX
Next Gen Portal in Office 365: April 2015. SUGUK
PPTX
Microsoft PowerApps Introduction by Usama Wahab Khan MVP
PPTX
Real World SharePoint Debacles
PPTX
My slides from SharePoint Saturday Oslo
PPTX
DWCNZ - Content Types: Love Them or Lose It
PPTX
Office 365 Groups: Deep Dive
PPTX
Managing permissions in SharePoint
PPTX
Next Generation Portals: Office 365
Typescript 101 introduction
Why learn french
Intro to behavioural law & economics
Chris O'Brien - Modern SharePoint sites and the SharePoint Framework - reference
From Solutions to Apps - Moving to SP2013
Introduction to AngularJS with the Microsoft Graph
Building Flexible SharePoint Solutions with AngularJS
Creating a Great User Experience in SharePoint by Marc Anderson - SPTechCon
Leveraging User Profiles and MySites
Collab365 Global Summit Slides
Session Slides from DEVintersection Europe
European SharePoint Conference - TH3
Next Gen Portal in Office 365: April 2015. SUGUK
Microsoft PowerApps Introduction by Usama Wahab Khan MVP
Real World SharePoint Debacles
My slides from SharePoint Saturday Oslo
DWCNZ - Content Types: Love Them or Lose It
Office 365 Groups: Deep Dive
Managing permissions in SharePoint
Next Generation Portals: Office 365
Ad

Similar to Typescript 102 angular and type script (20)

PPTX
Developing JavaScript Widgets
PPTX
Developing JavaScript Widgets
PPTX
Tech io spa_angularjs_20130814_v0.9.5
PPTX
ASP.NET 5 Overview - Post Build 2015
PDF
How angularjs saves rails
PDF
20 tips for website performance
PPTX
Angular2.0@Shanghai0319
PPTX
ASP.NET 5 Overview: Post RTM
PPTX
ASP.NET 5 Overview for Apex Systems
PPTX
Valentine with Angular js - Introduction
PPT
Google Web toolkit GWT 2.0 UiBinder Talk @ South Florida Google Technology Us...
PDF
Angularjs practical project experiences with javascript development in a bank
PPTX
ASP.NET 5 Overview
PPTX
Extending GWT
PDF
Introduction to Angular 2
PPTX
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
PPTX
Oleksandr Skachkov "Running С# in your Web Browser with WebAssembly"
PDF
Front End Development for Back End Developers - Devoxx UK 2017
PPTX
Building a REST API Microservice for the DevNet API Scavenger Hunt
PPTX
Azure Integration DTAP Series, How to go from Development to Production – Par...
Developing JavaScript Widgets
Developing JavaScript Widgets
Tech io spa_angularjs_20130814_v0.9.5
ASP.NET 5 Overview - Post Build 2015
How angularjs saves rails
20 tips for website performance
Angular2.0@Shanghai0319
ASP.NET 5 Overview: Post RTM
ASP.NET 5 Overview for Apex Systems
Valentine with Angular js - Introduction
Google Web toolkit GWT 2.0 UiBinder Talk @ South Florida Google Technology Us...
Angularjs practical project experiences with javascript development in a bank
ASP.NET 5 Overview
Extending GWT
Introduction to Angular 2
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
Oleksandr Skachkov "Running С# in your Web Browser with WebAssembly"
Front End Development for Back End Developers - Devoxx UK 2017
Building a REST API Microservice for the DevNet API Scavenger Hunt
Azure Integration DTAP Series, How to go from Development to Production – Par...

More from Bob German (19)

PPTX
Introduction to the Microsoft Bot Framework v4
PPTX
Adaptive cards 101
PPTX
Introduction to Teams Development - North American Collaboration Summit
PPTX
Future-proof Development for Classic SharePoint
PPTX
Azure for SharePoint Developers - Workshop - Part 4: Bots
PPTX
Azure for SharePoint Developers - Workshop - Part 3: Web Services
PPTX
Azure for SharePoint Developers - Workshop - Part 2: Azure Functions
PPTX
Azure for SharePoint Developers - Workshop - Part 1: Azure AD
PPTX
Azure for SharePoint Developers - Workshop - Part 5: Logic Apps
PPTX
Azure AD for browser-based application developers
PPTX
Mastering Azure Functions
PPTX
Going with the Flow: Rationalizing the workflow options in SharePoint Online
PPTX
Modern SharePoint, the Good, the Bad, and the Ugly
PPTX
Introduction to TypeScript
PPTX
TypeScript and SharePoint Framework
PPTX
German introduction to sp framework
PPTX
SPSNYC - Next Generation Portals
PPTX
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
PPTX
Enterprise Content Management + SharePoint 2013 - SPSNH
Introduction to the Microsoft Bot Framework v4
Adaptive cards 101
Introduction to Teams Development - North American Collaboration Summit
Future-proof Development for Classic SharePoint
Azure for SharePoint Developers - Workshop - Part 4: Bots
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 2: Azure Functions
Azure for SharePoint Developers - Workshop - Part 1: Azure AD
Azure for SharePoint Developers - Workshop - Part 5: Logic Apps
Azure AD for browser-based application developers
Mastering Azure Functions
Going with the Flow: Rationalizing the workflow options in SharePoint Online
Modern SharePoint, the Good, the Bad, and the Ugly
Introduction to TypeScript
TypeScript and SharePoint Framework
German introduction to sp framework
SPSNYC - Next Generation Portals
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
Enterprise Content Management + SharePoint 2013 - SPSNH

Recently uploaded (20)

PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
Save Business Costs with CRM Software for Insurance Agents
DOCX
The Future of Smart Factories Why Embedded Analytics Leads the Way
PPTX
Benefits of DCCM for Genesys Contact Center
PPTX
Using Bootstrap to Make Accessible Front-Ends(2).pptx
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
PDF
Emergency Mustering solutions – A Brief overview
PDF
Exploring AI Agents in Process Industries
PDF
Best Mobile App Development Company in Lucknow - Code Crafter Web Solutions
PDF
Jenkins: An open-source automation server powering CI/CD Automation
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
PDF
Best Practices for Rolling Out Competency Management Software.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
PDF
Comprehensive Salesforce Implementation Services.pdf
PDF
Perfecting Gamer’s Experiences with Performance Testing for Gaming Applicatio...
PPTX
Computer Hardware tool: hand tools, diagnostics, ESD and cleaning tools
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
PDF
Why Should Businesses Extract Cuisine Types Data from Multiple U.S. Food Apps...
PDF
Sensix-Tech-Pvt-Ltd-Company-Profile (1).pdf
A REACT POMODORO TIMER WEB APPLICATION.pdf
Save Business Costs with CRM Software for Insurance Agents
The Future of Smart Factories Why Embedded Analytics Leads the Way
Benefits of DCCM for Genesys Contact Center
Using Bootstrap to Make Accessible Front-Ends(2).pptx
The Role of Automation and AI in EHS Management for Data Centers.pdf
Emergency Mustering solutions – A Brief overview
Exploring AI Agents in Process Industries
Best Mobile App Development Company in Lucknow - Code Crafter Web Solutions
Jenkins: An open-source automation server powering CI/CD Automation
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
Best Practices for Rolling Out Competency Management Software.pdf
PTS Company Brochure 2025 (1).pdf.......
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
Comprehensive Salesforce Implementation Services.pdf
Perfecting Gamer’s Experiences with Performance Testing for Gaming Applicatio...
Computer Hardware tool: hand tools, diagnostics, ESD and cleaning tools
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
Why Should Businesses Extract Cuisine Types Data from Multiple U.S. Food Apps...
Sensix-Tech-Pvt-Ltd-Company-Profile (1).pdf

Typescript 102 angular and type script

  • 1. Practical TypeScript with AngularJS Typescript 102 Bob Goodearl RGood Software www.RGoodSoftware.com Bob German BlueMetal www.bluemetal.com
  • 2. Boston Code Camp 25 - Thanks to our Sponsors! • Platinum • Gold • Silver • Bronze • In-Kind Donations
  • 3. Bob German Bob Goodearl • Blog: http://bob1german.com/ • Linked In: https://www.linkedin.com/in/bgerman • Twitter: @Bob1German • Email: [email protected] • Website: http://www.rgoodsoftware.com • Linked In: https://www.linkedin.com/in/bgoodearl • Email: [email protected] Presenters
  • 4. Agenda • TypeScript Widget • Modules • Controllers • Services • TypeScript Definitions for REST Calls • TypeScript SPA with ASP.NET MVC • Anatomy of an AngularJS/MVC/TypeScript web app
  • 5. Setup steps: • Install VS Code • Install Node (https://nodejs.org/en/download) • npm install –g typescript • Ensure no old versions of tsc are on your path; VS adds: C:Program Files (x86)Microsoft SDKsTypeScript1.0 • In VS Code create tsconfig.json in the root of your folder { "compilerOptions": { "target": "es5“, "sourceMap": true } } • Use Ctrl+Shift+B to build – first time click the error to define a default task runner Edit task runner and un-comment the 2nd example in the default • npm install –g http-server (In a command prompt, run http-server and browse to http://localhost:8080/) VS Code Environment
  • 6. Setup steps: • Install Visual Studio • For VS2012 or 2013, install TypeScript extension • Build and debug the usual way • Consider WebEssentials for side by side TypeScript and JavaScript view (does not work in VS2015) Visual Studio Environment
  • 7. • Commonly used on the Internet called ”Web Widgets”, ”Plugins”, ”Embeds”, etc. • It’s just a clever piece of HTML and Javascript that acts like a web part • Often deployed by authors/end users seperately from the hosting application • Very handy in SharePoint and other content management systems What is a widget?
  • 8. What makes a good widget? 1 ISOLATED – so they won’t interfere with other widgets or the rest of the page Can you run multiple copies of the widget on a page? 2 EFFICIENT – so they load quickly Does the page get noticeably slower as you add widgets? 3 SELF-CONTAINED – so they’re easy to reuse Does the widget work without special page elements such as element ID’s, scripts, and CSS references? 4 MODERN – so they’re easier to write and maintain Is the widget written in a modern JavaScript framework such as AngularJS or Knockout?
  • 9. JavaScript Library allows you to run multiple Angular* apps on a page … <div> <!-- ng-app=“HelloApp” --> <div ng-controller="main as vm"> <h1>Hello{{vm.space()}}{{vm.name}}!</h1> Who should I say hello to? <input type="text" ng-model="vm.name" /> </div> <!-- Widget Wrangler loads scripts and boots the app --> <script type="text/javascript" src="pnp-ww.js“ ww-appName="HelloApp“ ww-appType="Angular“ ww-appScripts='[{"src": “~/angular.min.js", "priority":0}, {"src": “~/script.js", "priority":1}]'> </script> </div> Widget Wrangler * Also works with any JavaScript framework – or none at all
  • 10. demo AngularJS Widget in TypeScript • Model • Controller • Service • TypeScript Definitions for REST services
  • 12. demo AngularJS Widget in TypeScript • Model • Controller • Service • TypeScript Definitions for REST services
  • 13. Anatomy of an AngularJS/MVC/TypeScript web app • Why Integrate AngularJS and MVC? • Why add TypeScript? • Open source code you can experiment with • http://bit.ly/MvcNgTsDemo • Lessons Learned
  • 15. Generating TypeScript definitions • Experiments with TypeLite http://bit.ly/1WW9ckN • Other options (not yet explored) • Typewriter extension for Visual Studio http://bit.ly/VsX-Typewriter
  • 16. Resources Session Materials and Code Samples • http://bit.ly/bcc25ts102 TypeScript Playground • http://bit.ly/TSPlayground TS Def’ns from JSON • http://json2ts.com/
  • 17. An Insight company Thank you. Bob Goodearl Bob German

Editor's Notes

  • #2: This intermediate level session will build on the earlier introduction to TypeScript by showing examples of TypeScript in action with AngularJS 1.x. Bob German will begin by showing how to build light-weight widgets with Angular and TypeScript that can be deployed almost anywhere. Then Bob Goodearl will show a more advanced example of TypeScript Single Page Applications with Angular and ASP.NET MVC. In order to take advantage of this session, it will be helpful to have a basic understanding of AngularJS and ASP.Net MVC.
  • #14: Talk about: - Application Structure AngularJS routing Generating TypeScript definitions for your WebAPI JSON payloads Date Handling - Lessons Learned: - You don’t get type checking when you go through a non-Typescript framework – e.g. Angular promises - Debugging doesn’t always work as expected; generated variables get confused with their original names Show app first, then… Review app structure Type Safety -