SlideShare una empresa de Scribd logo
1 de 41
Welcome
Enhancing SharePoint
Experience using JavaScript
Pushkar Chivate
My Background
 Senior SharePoint and Web developer /
Application Architect
Agenda
- JavaScript:
- Why use JavaScript?
- Best Practices
- SharePoint app using some useful JavaScript
libraries
- Utility Libraries
- Data access Libraries
- Application Development Frameworks
- Libraries that Enhance User Interface
Why use JavaScript?
 Traditional SharePoint development
 On premises development
 Server side code
 App development
 In the cloud
 Client side code
JavaScript Best Practices
 Strict mode
 Equality operators
 Encapsulation
 Promises
Always use strict mode
 Declared with "use strict"
 Restrictions
 Cannot use a variable without declaring it
 Cannot write to a read-only property
 Cannot add properties to non-extensible objects
 Cannot illegally delete functions and variables
 Cannot define a property more than once in an object literal
 Cannot use a parameter name more than once in a function
 Cannot use reserved words, eval, or arguments, as names for functions and
variables
 The value of this in a function is no longer the window object
 Cannot declare functions inside of statements
 Cannot change the members of the arguments array
Always use ===
== Vs ===
!= Vs !==
JavaScript scopes
 Scope is at function level
 var is “private”
 this. is “public”
 No block level scope
Encapsulate your code
 Singleton pattern
 Module pattern
 Prototype pattern
Using the Singleton pattern
var department = {
name: "Sales",
getDepartmentInfo: function () {
alert("Department name is '" + this.name + "'");
}
};
department.getDepartmentInfo();
Using the Module pattern
var Organization = {};
Organization.Module = {};
Organization.Module.Department = function () {
//private members
var name,
setDepartmentInfo = function (n) { this.name = n; },
getDepartmentInfo = function () { alert(this.name); };
//public interface
return {
setDepartmentInfo: setDepartmentInfo,
getDepartmentInfo: getDepartmentInfo
}
}(); // self invoking function
// Advantages: Hides function members, Can use private and public members
Using the Prototype pattern
var Organization = {};
Organization.Department = function (n) {
this.name = n
};
Organization.Department.prototype = {
getDepartmentInfo: function () { alert(this.name); }
};
var department = new Organization.Department("Sales");
department.getDepartmentInfo();
// every object in JavaScript has prototype
// use of the keyword new
// useful for creating a lots of instances of one object
Promises
 Also called “Deferreds”
 Simplify asynchronous operations
jQuery Deferred
Demo
JavaScript Libraries
 Utility Libraries
 jQuery
 SPServices
 Data Libraries
 DataJS
 Application Framework Library
 AngularJS
 UI Library
 DataTables.js
 KendoUI
Deploying JavaScript Files
 Content Delivery Networks (CDNs)
 Use https
 Monkey-Patching
 Under Layouts folder
 Farm solutions
 Virtual File Systems
 Document Libraries
 Sandboxed solutions, Apps
Using the SharePoint RESTful endpoint
_api is alias for _vti_bin/client.svc
Custom Client Code
JavaScript
Library
Server
Client
.Net CLR
Overview of SharePoint & Office 365 JavaScript
Options
 Content Editor Web Part
 Script Editor Web Part
 SharePoint Designer
 <ScriptLink> or <Script>
 Server Side Code Injection
 RegisterClientScriptBlock vs RegisterStartupScript
 Web Parts/Delegate Controls/Application Pages
 CSS JavaScript Injection
Advantages of ScriptLink over
Script element
 Dependency loading
 Localized version of your library
 Control over when the file gets added
 Doesn’t load the file multiple times if it’s already
loaded once, this improves performance
 The ScriptLink element provides benefit only
when your library files reside in layouts folder, if
you are side loading the script files, you will not
get any real benefit with ScriptLink element
Angular.js
 Description
 Implements Model-View-Controller (MVC) for JavaScript
 Location
 http://angularjs.org/
 https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js
 NuGet
 Features
 Model-View-Controller
 Data Binding
 Routing
 Directives
 Factories
Angular Framework
Module
Routes
View Controller
Directives Factory
$scope
Modules
 A container for the components of the app
//module
var myapp = angular.module(“myApp", []);
<!-- html -->
<div data-ng-app = "MyApp">
Reference dependent modules
Directives
 Utilizes HTML5 custom data attributes
 Allows for the addition of custom attributes starting with
data-
 Angular uses directives for declarative programming
 Angular directives start with “ng-”
 data-ng-app, defines scope of the framework
 data-ng-controller, invokes a controller
 data-ng-click, handles click event
Directives
<!DOCTYPE html>
<html data-ng-app=“myApp”>
<head></head>
<body>
<input type="text" data-ng-model="displayName"/>
<div data-ng-click="update" ng-controller="myCtrl">
</div>
</body>
</html>
Initializes the app. Can be
anonymous or named.
Creates a property on the
ViewModel
References a controller
named “myCtrl”, which
creates a new ViewModel.
References a
controller method to
call on a click event
Simple Data Binding
<div ng-app=“myApp">
<div ng-controller="myCtrl">
<input type="text" data-ng-model="firstName"/>
<div>{{firstName}}</div>
</div>
</div>
• Binds ViewModels to HTML elements
• Uses {{…}} syntax
• References a property of a ViewModel
• Supports two-way binding
This example will display
whatever the user types
Controllers
//controller
myapp.controller(“myCtrl", ["$scope",
function welcomeCtrl($scope) {
//model
$scope.welcomeMessage = "Hi";
}
);
<!-- html -->
<div data-ng-controller=“myCtrl">
• Build up the $scope (a.k.a, View Model)
View Binding
<div ng-app=“myApp">
<div ng-controller=“myCtrl">
<h3>{{welcomeMessage}}</h3>
</div>
</div>
• Bind the $scope to the HTML elements
AngularJS
Demo
Angular-1 View Synchronization
•Declarative
•Separation between template and code
•Two-way data binding
•Stateful
•Nested Scopes (Controller As)
•Unidirectional flow
Angular-2 what’s coming
• Still declarative
• Separation between template and code
• 3 types of directives – components
(directives, controllers), decorators,
templates (transformative, e.g. ng-if)
• Support for unidirectional data flow
• Three models: stateful, reactive, immutable
• Controllers are folded into components
JavaScript Library: DataTables
 DataTables (http://www.datatables.net/)
JavaScript Libraries
 KendoUI (http://www.telerik.com/kendo-ui)
 Moment.js (http://momentjs.com/)
Moment.js
 Date arithmetic
 moment().add(‘day’, 5);
 Date formatting
DataJS
 Description
 OData client for JavaScript
 Location
 http://datajs.codeplex.com
 Features
 Cross-browser support
 Data caching
 Batch operations
Retrieving OData
"../_api/web/lists/getByTitle(‘SoftwareOrder')/itemCount"
"GET"
"accept" "application/json;odata=verbose"
function
Caching Data
var
"contacts"
"../_api/web/lists/getByTitle(‘SoftwareOrder')/items"
"?$select=Id,Title,SoftwareCategory,UserName"
"&$orderby=Title"
JavaScript Library: SPServices
 SPServices
(http://spservices.codeplex.com/)
JavaScript Snippet: JavaScript on all Pages
 Registering JavaScript on All Pages in
Office 365
Recap
We Looked at…
- JavaScript best practices
- JavaScript libraries
Utility Libraries
Data access Libraries
Application Development Frameworks
Libraries that Enhance User Interface
- Developing application for Office 365 SharePoint and use of
JavaScript libraries
References
- Codeplex
- Github OfficeDev/Pnp
- Youtube, MSDN and other sites on the web
Thank you.

Más contenido relacionado

La actualidad más candente

Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
David Xi Peng Yang
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
Tieturi Oy
 

La actualidad más candente (20)

AngularJs (1.x) Presentation
AngularJs (1.x) PresentationAngularJs (1.x) Presentation
AngularJs (1.x) Presentation
 
ASP .net MVC
ASP .net MVCASP .net MVC
ASP .net MVC
 
Angular JS
Angular JSAngular JS
Angular JS
 
Data binding 入門淺談
Data binding 入門淺談Data binding 入門淺談
Data binding 入門淺談
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
AngularJS
AngularJSAngularJS
AngularJS
 
Angular js presentation at Datacom
Angular js presentation at DatacomAngular js presentation at Datacom
Angular js presentation at Datacom
 
Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
AtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using nowAtlasCamp 2015: Web technologies you should be using now
AtlasCamp 2015: Web technologies you should be using now
 
AtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlasCamp 2015: Connect everywhere - Cloud and Server
AtlasCamp 2015: Connect everywhere - Cloud and Server
 
React JS .NET
React JS .NETReact JS .NET
React JS .NET
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
AtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-onsAtlasCamp 2015: Using add-ons to build add-ons
AtlasCamp 2015: Using add-ons to build add-ons
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web Apps
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5TechDays 2013 Jari Kallonen: What's New WebForms 4.5
TechDays 2013 Jari Kallonen: What's New WebForms 4.5
 

Similar a SharePoint Saturday Atlanta 2015

django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
Kevin Wu
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
China Science Challenge
China Science ChallengeChina Science Challenge
China Science Challenge
remko caprio
 

Similar a SharePoint Saturday Atlanta 2015 (20)

AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Pyramid patterns
Pyramid patternsPyramid patterns
Pyramid patterns
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
Droidcon Paris 2015
Droidcon Paris 2015Droidcon Paris 2015
Droidcon Paris 2015
 
Django cheat sheet
Django cheat sheetDjango cheat sheet
Django cheat sheet
 
Basics of AngularJS
Basics of AngularJSBasics of AngularJS
Basics of AngularJS
 
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
JavaScripters Event Oct 22, 2016 · 2:00 PM: Common Mistakes made by Angular D...
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-ons
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Google app engine by example
Google app engine by exampleGoogle app engine by example
Google app engine by example
 
James Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 PatternsJames Turner (Caplin) - Enterprise HTML5 Patterns
James Turner (Caplin) - Enterprise HTML5 Patterns
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular Framework
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
intro to Angular js
intro to Angular jsintro to Angular js
intro to Angular js
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
China Science Challenge
China Science ChallengeChina Science Challenge
China Science Challenge
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

SharePoint Saturday Atlanta 2015

  • 2. My Background  Senior SharePoint and Web developer / Application Architect
  • 3. Agenda - JavaScript: - Why use JavaScript? - Best Practices - SharePoint app using some useful JavaScript libraries - Utility Libraries - Data access Libraries - Application Development Frameworks - Libraries that Enhance User Interface
  • 4. Why use JavaScript?  Traditional SharePoint development  On premises development  Server side code  App development  In the cloud  Client side code
  • 5. JavaScript Best Practices  Strict mode  Equality operators  Encapsulation  Promises
  • 6. Always use strict mode  Declared with "use strict"  Restrictions  Cannot use a variable without declaring it  Cannot write to a read-only property  Cannot add properties to non-extensible objects  Cannot illegally delete functions and variables  Cannot define a property more than once in an object literal  Cannot use a parameter name more than once in a function  Cannot use reserved words, eval, or arguments, as names for functions and variables  The value of this in a function is no longer the window object  Cannot declare functions inside of statements  Cannot change the members of the arguments array
  • 7. Always use === == Vs === != Vs !==
  • 8. JavaScript scopes  Scope is at function level  var is “private”  this. is “public”  No block level scope
  • 9. Encapsulate your code  Singleton pattern  Module pattern  Prototype pattern
  • 10. Using the Singleton pattern var department = { name: "Sales", getDepartmentInfo: function () { alert("Department name is '" + this.name + "'"); } }; department.getDepartmentInfo();
  • 11. Using the Module pattern var Organization = {}; Organization.Module = {}; Organization.Module.Department = function () { //private members var name, setDepartmentInfo = function (n) { this.name = n; }, getDepartmentInfo = function () { alert(this.name); }; //public interface return { setDepartmentInfo: setDepartmentInfo, getDepartmentInfo: getDepartmentInfo } }(); // self invoking function // Advantages: Hides function members, Can use private and public members
  • 12. Using the Prototype pattern var Organization = {}; Organization.Department = function (n) { this.name = n }; Organization.Department.prototype = { getDepartmentInfo: function () { alert(this.name); } }; var department = new Organization.Department("Sales"); department.getDepartmentInfo(); // every object in JavaScript has prototype // use of the keyword new // useful for creating a lots of instances of one object
  • 13. Promises  Also called “Deferreds”  Simplify asynchronous operations
  • 15. JavaScript Libraries  Utility Libraries  jQuery  SPServices  Data Libraries  DataJS  Application Framework Library  AngularJS  UI Library  DataTables.js  KendoUI
  • 16. Deploying JavaScript Files  Content Delivery Networks (CDNs)  Use https  Monkey-Patching  Under Layouts folder  Farm solutions  Virtual File Systems  Document Libraries  Sandboxed solutions, Apps
  • 17. Using the SharePoint RESTful endpoint _api is alias for _vti_bin/client.svc Custom Client Code JavaScript Library Server Client .Net CLR
  • 18. Overview of SharePoint & Office 365 JavaScript Options  Content Editor Web Part  Script Editor Web Part  SharePoint Designer  <ScriptLink> or <Script>  Server Side Code Injection  RegisterClientScriptBlock vs RegisterStartupScript  Web Parts/Delegate Controls/Application Pages  CSS JavaScript Injection
  • 19. Advantages of ScriptLink over Script element  Dependency loading  Localized version of your library  Control over when the file gets added  Doesn’t load the file multiple times if it’s already loaded once, this improves performance  The ScriptLink element provides benefit only when your library files reside in layouts folder, if you are side loading the script files, you will not get any real benefit with ScriptLink element
  • 20. Angular.js  Description  Implements Model-View-Controller (MVC) for JavaScript  Location  http://angularjs.org/  https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js  NuGet  Features  Model-View-Controller  Data Binding  Routing  Directives  Factories
  • 22. Modules  A container for the components of the app //module var myapp = angular.module(“myApp", []); <!-- html --> <div data-ng-app = "MyApp"> Reference dependent modules
  • 23. Directives  Utilizes HTML5 custom data attributes  Allows for the addition of custom attributes starting with data-  Angular uses directives for declarative programming  Angular directives start with “ng-”  data-ng-app, defines scope of the framework  data-ng-controller, invokes a controller  data-ng-click, handles click event
  • 24. Directives <!DOCTYPE html> <html data-ng-app=“myApp”> <head></head> <body> <input type="text" data-ng-model="displayName"/> <div data-ng-click="update" ng-controller="myCtrl"> </div> </body> </html> Initializes the app. Can be anonymous or named. Creates a property on the ViewModel References a controller named “myCtrl”, which creates a new ViewModel. References a controller method to call on a click event
  • 25. Simple Data Binding <div ng-app=“myApp"> <div ng-controller="myCtrl"> <input type="text" data-ng-model="firstName"/> <div>{{firstName}}</div> </div> </div> • Binds ViewModels to HTML elements • Uses {{…}} syntax • References a property of a ViewModel • Supports two-way binding This example will display whatever the user types
  • 26. Controllers //controller myapp.controller(“myCtrl", ["$scope", function welcomeCtrl($scope) { //model $scope.welcomeMessage = "Hi"; } ); <!-- html --> <div data-ng-controller=“myCtrl"> • Build up the $scope (a.k.a, View Model)
  • 27. View Binding <div ng-app=“myApp"> <div ng-controller=“myCtrl"> <h3>{{welcomeMessage}}</h3> </div> </div> • Bind the $scope to the HTML elements
  • 29. Angular-1 View Synchronization •Declarative •Separation between template and code •Two-way data binding •Stateful •Nested Scopes (Controller As) •Unidirectional flow
  • 30. Angular-2 what’s coming • Still declarative • Separation between template and code • 3 types of directives – components (directives, controllers), decorators, templates (transformative, e.g. ng-if) • Support for unidirectional data flow • Three models: stateful, reactive, immutable • Controllers are folded into components
  • 31. JavaScript Library: DataTables  DataTables (http://www.datatables.net/)
  • 32. JavaScript Libraries  KendoUI (http://www.telerik.com/kendo-ui)  Moment.js (http://momentjs.com/)
  • 33. Moment.js  Date arithmetic  moment().add(‘day’, 5);  Date formatting
  • 34. DataJS  Description  OData client for JavaScript  Location  http://datajs.codeplex.com  Features  Cross-browser support  Data caching  Batch operations
  • 37. JavaScript Library: SPServices  SPServices (http://spservices.codeplex.com/)
  • 38. JavaScript Snippet: JavaScript on all Pages  Registering JavaScript on All Pages in Office 365
  • 39. Recap We Looked at… - JavaScript best practices - JavaScript libraries Utility Libraries Data access Libraries Application Development Frameworks Libraries that Enhance User Interface - Developing application for Office 365 SharePoint and use of JavaScript libraries
  • 40. References - Codeplex - Github OfficeDev/Pnp - Youtube, MSDN and other sites on the web