SlideShare ist ein Scribd-Unternehmen logo
ANGULARJS UND TYP-D'OH!3
ChristianHerberger
ÜBER MICH
Integrator
PHP-Entwickler
FE-Entwickler
PUNKT.DE
TYPO3-Komplettpakete in Karlsruhe
25 Mitarbeiter
DER ROTE FADEN
Was istAngularJS(undwas kannes)?(LiveundinFarbe!)
WiekannmanAngularJSmitTYPO3nutzen?
Stolpersteine
Ausblick
ANGULARJS
¡Ay, caramba!
WAS IST ANGULARJS?
HTML enhanced for web apps
MVC/MVVM
TwoWay/BidirectionalDataBinding
DependencyInjection
Direktivenals ErweiterungvonHTML
TestbarkeitvonGrundauf
DieDreiD
MVC/MVVM
MVC
MVVM
BEISPIEL
... kommtgleich
TWOWAY/BIDIRECTIONAL DATA BINDING
<scripttype="text/javascript"src="Resources/JavaScript/angular.js">
</script>
<divng-app>
<inputtype="text"ng-model="name"
placeholder="BitteNameneingeben"/><br/>
<p>Hallo,ichbin{{name}}</p>
</div>
Bitte Namen eingeben
Hallo, ich bin
A BIT MORE...
<scripttype="text/javascript"src="Resources/JavaScript/angular.js">
</script>
<scripttype="text/javascript">
angular.module('displayNameApp',[]);
angular.module('displayNameApp').controller('displayNameController',function($scope)
$scope.name='ApuNahasapemapetilon';
$scope.resetName=function(){
$scope.name='ApuNahasapemapetilon';
};
});
</script>
<divng-app="displayNameApp">
<divng-controller="displayNameController">
<inputtype="text"ng-model="name"
placeholder="BitteNameneingeben"/><br/>
<p>Hallo,ichbin{{name}}</p>
<inputtype="button"ng-click="resetName()">
</div>
</div>
Apu Nahasapemapetilon
Hallo, ich bin Apu Nahasapemapetilon
Reset Name
WEITERE MÖGLICHKEITEN
ng-repeatfür AusgabevonArrays
selectmitng-options
ng-initals Konstruktor
VerschachtelteController mitVererbung
DEPENDENCY INJECTION
WAS IST DI?
BenötigteinObjekteinanderes Objektals Abhängingkeit, ziehtes
einzentralabgelegtes Objektabundmuss es nichtselbst
erstellen
Fuktioniertbeiallen"Factories"(Modulen, Controllern,
Direktiven, Services, ...)
BEISPIEL
<scripttype="text/javascript">
angular.module('displayNameApp',['fremdModul']);
angular.module('displayNameApp').controller('displayNameController',
function($scope,$http,eigenerService){
$scope.name='ApuNahasapemapetilon';
$scope.resetName=function(){
$scope.name=$http.get(...);
varblubb=eigenerService.doSomething();
};
});
angular.module('displayNameApp').factory('eigenerService',
function($http){
return{
doSomething=function(){...};
};
});
</script>
DI VERÄNDERN
Angular bieteteinen injector mitFunktionen wie get()
Abhängigvon Conditions, oder jedem eingenen Code, andere
Dependencies einspielen
BEISPIEL
<scripttype="text/javascript">
angular.module('displayNameApp',[]);
angular.module('displayNameApp').controller('displayNameController',
function($scope,$http){
if($scope.testMode){
$http=angular.injector.get('myHttpMock');
}
$scope.name='ApuNahasapemapetilon';
$scope.resetName=function(){
$scope.name=$http.get(...);
};
});
</script>
DIREKTIVEN ALS ERWEITERUNG VON HTML
WÄR DAS NICHT GENIAL?
<name-listlast-name="Simpson"></name-list>
OUTPUT:
Homer Simpson
MargeSimpson
BartSimpson
LisaSimpson
MaggieSimpson
ES IST SO GENIAL!
DAS "NORMALE" JAVASCRIPT
<scripttype="text/javascript">
angular.module('displayNameApp',[]);
angular.module('displayNameApp').directive('nameList',function($http){
return{
scope:{
lastName:'@lastName'
},
restrict:'E',
templateUrl:'nameList.html',
link:function(scope){
$http.get(/*ajaxcallwithlastname*/)
.success(function(resonseData){
scope.nameList=responseData.nameList;
});
}
}
});
</script>
DAS "TEMPLATE"
<div>
<scripttype="text/ng-template"id="nameList.html">
<div>
<ul>
<ling-repeat="nameinnameList">{{name}}{{lastName}}</li>
</ul>
</div>
</script>
<name-listlast-name="Simpson"></name-list>
</div>
BEISPIEL
... gibt's hier keins -nichtrelevantfür unsereAnwendung
TESTBARKEIT
UNIT TESTS
GuteIntegrationinaktuelleTestframeworks (Karma, Jasmine)
DurchDIeinfachCode-Einheitenzuisolieren
Jeder Service, Controller, ... kanneinzelnlosgelöstaufgerufen
werden
Inder Dokugibtes Test-Dokufür jedeVariante
"END TO END"-TEST
ungefähr wieOberflächentest-Aufrufder Funktion, Vergleich
des Outputs mitdefiniertenMocks
angular-mockals Modulfür fertigeMocks
IntegrationvonHTML-Template-Tools inKarma/Jasmine
JS-Tests laufenaufBrowsern->RealeBedingungen
INTEGRATION IN TYPO3
IDEEN
EineActionfür dieApp(=>SinglePageApp)
ActionkomplettCachebar machen
Models mit$exposedProperties undgetExposedProperties()
anreichern
ObjectToJson-Parser nutzen, JSONanng-init-Aufrufe
übergeben
Fluidnutzen!
Angular-Templates als Partials ->Ordnung, Fluid;)
KommunikationmitTYPO3über AJAXundeID
ZugriffsrechteaufdieSeiteunddas Pluginmitder App
STOLPERSTEINE
STOLPERSTEINE
Fluid+JSON='Array'-><![CDATA[nutzen!
array('name'=>'value') wirdinJSONeinObjektunddamit
nichtsortierbar
JavaScriptisteineasnychronarbeitendeSprache
Anderes JavaScriptkanndieAppstören, Ladezeitverlängern
usw. ->Möglichstlosgelösteinbinden
AUSBLICK
Fragen?Antworten!Diskussion?
Vielen Dank für die Aufmerksamkeit!

Weitere ähnliche Inhalte

Empfohlen (20)

PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
PDF
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
PDF
Everything You Need To Know About ChatGPT
Expeed Software
 
PDF
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
PDF
Skeleton Culture Code
Skeleton Technologies
 
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
PDF
Content Methodology: A Best Practices Report (Webinar)
contently
 
PPTX
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
PDF
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
PDF
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
PDF
Getting into the tech field. what next
Tessa Mero
 
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
PDF
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
 
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
 
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
 
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
 
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 

AngularJS und TYP-D'oh!3