SHAREPOINT SATURDAY PRESENTATION by Keith Rimington REAL EXPERIENCES WITH ANGULARJS AND SHAREPOINT.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Introducing JavaScript
#spsevents #spsphx SPS EVENTS PHX Know REST for the Query AN INTRODUCTION TO REST FOR SHAREPOINT 2013 ERIC J OSZAKIEWSKI, MCTS, MS, MCPS.
Microsoft ® Official Course Client-Side SharePoint Development SharePoint Practice Microsoft SharePoint 2013.
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
Creating Single Page Applications with ASP.NET & Angular JS An introduction by Mitchel Sellers.
SharePoint Saturday Sponsors Gold Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
@lestersconyers #spsevents #spsphx SPS EVENTS PHX SharePoint and Angular Sitting in a Tree… LESTER SCONYERS.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Single Page Applications with AngluarJS Bill Wolff Rob Keiser
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
Department of Information Technology e-Michigan Web Development 0 HTML Form Creation in the Vignette Content Management Application.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
@ScotHillier (function () { }());
JavaScript & jQuery the missing manual Chapter 11
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Internet Skills An Introduction to HTML Alan Noble Room 504 Tel: (44562 internal)
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
ASP.NET Web API Udaiappa Ramachandran NHDN-Nashua.NET/Cloud Computing UG Lead Blog:
AngularJS Routing Routes, Route Parameters, Templates, Location, Navigation SoftUni Team Technical Trainers Software University
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Krishna Mohan Koyya Glarimy Technology Services
AngularJS Directives Defining Custom Directives SoftUni Team Technical Trainers Software University
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
Introduction to the SharePoint 2013 REST API. 2 About Me SharePoint Solutions Architect at Sparkhound in Baton Rouge
Daniel van Wyk – 3fifteen – SA Developer.Net – Information Worker Group.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Keyword Searching Weighted Federated Search with Key Word in Context Date: 10/2/2008 Dan McCreary President Dan McCreary & Associates
Lessons Learned (from the Simple HTML Editor) A Presentation for the Microsoft Access SIG of the North Texas PC User Group by Larry Linson. © Copyright.
Controllers and Markup Controllers, $scope, Markup, Directives, Expressions, Binding, Filters, Validation SoftUni Team Technical Trainers Software University.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
REpresentational State Transfer.  Resources  Representations  Verbs  Links  Headers  HTTP Status Codes.
AngularJS AJAX.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Understand haxejs-angular app How to write app in OOP(Haxe) and Dependency Injection Way(Angular)?
1111 Creating HTML Programatically Objectives You will be able to Invoke C# code on the server from an ASP.NET page. Write C# code to create HTML.
AngularJS $resource service. Add angular-resouce: Add the dependency: angular.module('myApp', ['ngResource']); Configure.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
JQUERY AND AJAX
Preliminary Software design and Development a Welcome to our Coding Day session one.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
Martin Kruliš by Martin Kruliš (v1.0)1.
JQuery form submission CIS 136 Building Mobile Apps 1.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Chapter 5 Angularjs. Content Overview How to program with Angularjs Directives Expressions Controllers Filters HTML DOM Forms and Includes Ajax Scopes.
Web API - Introduction AJAX, Spring Data REST SoftUni Team Web API
APAN SharePoint Permissions
Built-in and Custom Services
API Security Auditing Be Aware,Be Safe
Data Virtualization Tutorial… CORS and CIS
An introduction to REST for SharePoint 2013
APAN SharePoint Permissions
What is REST API ? A REST (Representational State Transfer) Server simply provides access to resources and the REST client accesses and presents the.
WEB API.
How the VIAF Magic Happens
Working with different JavaScript frameworks and libraries
MIS JavaScript and API Workshop (Part 3)
Lecture 5: Functions and Parameters
AngularJS Michael Kang August 20th 2015.
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Presentation transcript:

SHAREPOINT SATURDAY PRESENTATION by Keith Rimington REAL EXPERIENCES WITH ANGULARJS AND SHAREPOINT

Please remember to thank our sponsors.

SHAREPOINT SATURDAY PRESENTATION A little tour of Insider

SHAREPOINT SATURDAY PRESENTATION A little tour of Insider

SHAREPOINT SATURDAY PRESENTATION A little tour of Insider

SHAREPOINT SATURDAY PRESENTATION A little tour of Insider

SHAREPOINT SATURDAY PRESENTATION A little tour of Insider

SHAREPOINT SATURDAY PRESENTATION A little tour of Insider

SHAREPOINT SATURDAY PRESENTATION Demo

SHAREPOINT SATURDAY PRESENTATION Intro to AngularJS “AngularJS lets you extend HTML vocabulary for your application.” “The resulting environment is extraordinarily expressive, readable, and quick to develop”

SHAREPOINT SATURDAY PRESENTATION Intro to AngularJS

SHAREPOINT SATURDAY PRESENTATION Source Code

SHAREPOINT SATURDAY PRESENTATION AngularJS Basics (Markup) Calculate

SHAREPOINT SATURDAY PRESENTATION AngularJS Basics (Controllers) function SumCtrl(scope) { // Optional default values scope.addend1 = 1076; scope.addend2 = 532; // Scope operations scope.calculate = function calculate() { scope.sum = scope.addend1 + scope.addend2; }

SHAREPOINT SATURDAY PRESENTATION AngularJS Basics (Modules) // Build the AngularJS module and injector database. angular.module('app', []).controller('SumCtrl', SumCtrl); //.constant('Name', ConstantValue) //.factory('ServiceName', ServiceFunction) //.directive('DirectiveName', DirectiveFunction) // Define dependency injections. SumCtrl.$inject = ['$scope']; // Load the application angular.bootstrap(document, ['app']);

SHAREPOINT SATURDAY PRESENTATION Demo

SHAREPOINT SATURDAY PRESENTATION AngularJS Vocabulary - Databinding ng-bind ng-bind-html ng-bind-template ng-model ng-options ng-href, ng-src Bind a simple value as text Bind a simple value as html Bind an expression as text Two-way bind to an input Bind a list of options to a select Bind overrides to certain attributes

SHAREPOINT SATURDAY PRESENTATION AngularJS Vocabulary - Control ng-if ng-show ng-hide ng-disabled ng-class ng-style Emit element if truthy Display element if truthy Hide element if truthy Disable input if truthy Dictionary. Assign class for each truthy attribute Dictionary. Assign style for each truthy attribute

SHAREPOINT SATURDAY PRESENTATION AngularJS Vocabulary - Events ng-click ng-dblclick ng-change ng-focus, ng-blur ng-keyup, ng-keydown ng-cut, ng-copy, ng-paste

SHAREPOINT SATURDAY PRESENTATION AngularJS AJAX

SHAREPOINT SATURDAY PRESENTATION AngularJS Service function RestSvc(http, SPContextInfo) { var apiBaseUrl = SPContextInfo.webServerRelativeUrl.replace(/\/$/, "") + "/_api/web/lists/GetByTitle('Todo')/Items"; var service = { 'getList': getList, 'getSingle': getSingle, 'create': create, 'update': update, 'remove': remove }; return service; }

SHAREPOINT SATURDAY PRESENTATION What kind of JSON do you want? (JSONLight) –Accept: application/json; odata=verbose –Accept: application/json –Accept: application/json; odata=minimalmetadata –Accept: application/json; odata=nometadata

SHAREPOINT SATURDAY PRESENTATION Select Top 100 function getList() { return http.get(apiBaseUrl); } // Results, abbreviated for clarity. { "odata.nextLink": " "value": [ { "odata.etag": "\"1\"", "Id": 1, "Title": "Learn about international cheeses", "Priority": "A", "Completed": false, },... ] }

SHAREPOINT SATURDAY PRESENTATION Select Single function getSingle(id) { return http.get(apiBaseUrl + "(" + id + ")" ); } // Results, abbreviated for clarity. { "odata.etag": "\"1\"", "Id": 1, "Title": "Learn about international cheeses", "Priority": "A", "Completed": false, }

SHAREPOINT SATURDAY PRESENTATION Create New Item // Start with the writable data. Anything you leave out uses the default value. var item = { "Title": "Learn about international cheeses", "Priority": "A", "Completed": false, } function create(item) { return http.post(apiBaseUrl, item); } // Results look just like selecting a single.

SHAREPOINT SATURDAY PRESENTATION Request Digests Any call that has side effects also requires an extra HTTP header, X- RequestDigest Where do I get a form digest? – –Send a POST to _api/contextinfo // Results, abbreviated for clarity. { "FormDigestTimeoutSeconds": 1800, "FormDigestValue": "0xCBC blah blah blah gibberish,20 Feb :54: ", "SiteFullUrl": " "WebFullUrl": " }

SHAREPOINT SATURDAY PRESENTATION AngularJS HTTP Interceptor Intercept HTTP calls before they leave the browser Inspect HTTP configuration and make changes Can return either: –A new configuration –A promise to return a new configuration Our strategy will grab a new digest on demand only if needed and inject it into the config

SHAREPOINT SATURDAY PRESENTATION AngularJS Promise var d = $q.defer() d.resolve()d.reject()d.promise promise.then( resolved, resolved, rejected rejected);

SHAREPOINT SATURDAY PRESENTATION AngularJS HTTP Interceptor (1 of 3) // Add a factory to the module linked to this interceptor. // Then configure your module to push the object onto the interceptors list. function SPRestInterceptor(injector, q, SPContextInfo) { var context = {}; var expiry = new Date(); var contextUrl = SPContextInfo.webServerRelativeUrl.replace(/\/$/, '') + "/_api/contextinfo"; var webUrl = SPContextInfo.webServerRelativeUrl; var interceptor = { request: InterceptRequest } return interceptor; }

SHAREPOINT SATURDAY PRESENTATION AngularJS HTTP Interceptor (2 of 3) function EnsureContext() { var deferred = q.defer(); if (expiry > new Date()) { deferred.resolve(context); } else { var http = injector.get('$http'); http.post(contextUrl). success(function (data) { angular.extend(context, data); expiry = new Date(); expiry.setSeconds(expiry.getSeconds + data.FormDigestTimeoutSeconds); deferred.resolve(context); }). error(function (data) { deferred.reject(data || 'Unknown error'); }); } return deferred.promise; }

SHAREPOINT SATURDAY PRESENTATION AngularJS HTTP Interceptor (3 of 3) function InterceptRequest(config) { if (config && config.url && config.url.indexOf(webUrl) == 0) { config.withCredentials = true; if (config.method != "GET" && config.url != contextUrl) { var deferred = q.defer(); EnsureContext().then( function (digest) { config.headers = config.headers || {}; config.headers['X-RequestDigest'] = digest.FormDigestValue; deferred.resolve(config); }, function (reason) { deferred.reject(reason); }); return deferred.promise; } return config; }

SHAREPOINT SATURDAY PRESENTATION AngularJS HTTP Interceptor (4 of 3)! angular.module('ngSharePoint', []).config(SPConfigModule).value('SPContextInfo', _spPageContextInfo).factory('SPRestInterceptor', SPRestInterceptor) SPConfigModule.$inject = ['$httpProvider']; SPRestInterceptor.$inject = ['$injector', '$q', 'SPContextInfo']; function SPConfigModule (provider) { provider.interceptors.push('SPRestInterceptor'); } function SPRestInterceptor (injector, q, SPContextInfo) {... }

SHAREPOINT SATURDAY PRESENTATION Delete Item // Deletes cause side effects, and require an X-RequestDigest header. // Our HTTP interceptor takes care of that for us. // Deletes also have other required headers, IF-MATCH, and X-HTTP-Method. function remove(item) { var config = { headers: { 'IF-MATCH': '*', 'X-HTTP-Method': 'DELETE' } }; return http.post(apiBaseUrl + "(" + item.Id + ")", null, config); }

SHAREPOINT SATURDAY PRESENTATION Update Item // Updates cause side effects, and require an X-RequestDigest header. // Our HTTP interceptor takes care of that for us. // Updates also have other required headers, IF-MATCH, and X-HTTP-Method. // The HTTP method can be PUT (to replace) or MERGE (to update). // Updates produce a 204 No Content response. // To get the new Etag, check the Etag header of the response. function update(item) { var config = { headers: { 'IF-MATCH': item["odata.etag"], 'X-HTTP-Method': 'MERGE' } }; var patch = { Title: item.Title, Priority: item.Priority, Completed: item.Completed }; return http.post(apiBaseUrl + "(" + item.Id + ")", patch, config); }

SHAREPOINT SATURDAY PRESENTATION Demo

SHAREPOINT SATURDAY PRESENTATION by Keith Rimington CONCLUSION