SlideShare a Scribd company logo
1 of 15
Vasileuski Vitali
@VintJS
real experience, problems & solutions
https://github.com/vasvitaly/tree
Why we started using JS framework.
Why we started using JS framework.
Why Angular?
● Two-way data binding
● Declarative style. Seems like HTML on
steroids.
● Good collection of built-in components.
● Well testable
Easy to start
● Tutorial for beginners
● Good enough documentation
● Big and fast-growing community.
Important elements of powerful apps
● ng-repeat="item in collection"
● ng-include="expression"
● $resource
Problems we faced.
● Convert data, got from server before using
it.
● No if – else in Views
● Rendering trees.
● Dark side of two-way binding
● How to bind Angular to Rails app?
● Using jQuery and jQueryUI in AngularJS app
Convert data, got from server before
using it
Just do it in request's callback.
$scope.questions = Question.query(
{screener_id:$scope.screener.id},
function(){
Some convert actions
...
$scope.questions = converted_data;
}
);
No if – else in Views
● ng-show | ng-hide – for simple cases
● ng-include=”expression” - for choosing what
partial to render
Rendering trees
<div ng-app="treeApp">
<div ng-controller="TreeCtrl">
<script type="text/ng-template" id="node.html">
<span>{{node.name}}</span>
<ul>
<li ng-repeat="node in node.nodes"
ng-include="'node.html'"></li>
</ul>
</script>
<div id=”tree” class=”tree“>
<ul>
<li ng-repeat="node in nodes" ng-include="'node.html'"></li>
</ul>
</div>
</div>
Dark side of two-way binding
If you want Angular to not watch your variable,
just initialize it out of scope.
How to bind Angular to Rails app?
● gem 'angularjs-rails'
● Configure $httpProvider.defaults in your app or controller
app = angular.module('treeApp',["ngResource"])
.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/json'
$httpProvider.defaults.headers.put['Content-Type'] = 'application/json'
# assumes the presence of jQuery
token = $("meta[name='csrf-token']").attr("content")
$httpProvider.defaults.headers.post['X-CSRF-Token'] = token
$httpProvider.defaults.headers.put['X-CSRF-Token'] = token
$httpProvider.defaults.headers.common['X-CSRF-Token'] = token
}])
jQuery and jQueryUI with AngularJS
angular.module('treeBuilder', [])
.directive('tree', ['$document', function($document){
return {
options: {},
scope: true,
link: function(scope, elm, attrs) {
moveNode = function(moved_node, lnode, rnode) {
scope.moveNodeTo(opts)
}
$document.ready( function() {
$( "#tree" ).sortable(
items: "li",
update: function(event, ui) {
moveNode(moved_node, left_node, right_node);
}
);
}
}
}
}]);
What is in a result?
● Angular is a real friend for fast developing real
WEB 3.0 applications.
● Most of problems are already solved, see docs and
Google+
● Most of problems can be solved thinking Angular
way.
С чего начать?
http://angularjs.org
Example Editable Tree
application
https://github.com/vasvitaly/tree

More Related Content

What's hot

Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
Wei Ru
 
BDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - UdayBDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - Uday
Udaya Kumar
 

What's hot (20)

AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 
Angular js
Angular jsAngular js
Angular js
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 
Introducing AngularJS
Introducing AngularJSIntroducing AngularJS
Introducing AngularJS
 
Boosting Your Productivity, with Backbone & RactiveJS
Boosting Your Productivity, with Backbone & RactiveJS Boosting Your Productivity, with Backbone & RactiveJS
Boosting Your Productivity, with Backbone & RactiveJS
 
AngularJS best-practices
AngularJS best-practicesAngularJS best-practices
AngularJS best-practices
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Step by Step - AngularJS
Step by Step - AngularJSStep by Step - AngularJS
Step by Step - AngularJS
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
React vs-angular-mobile
React vs-angular-mobileReact vs-angular-mobile
React vs-angular-mobile
 
Angular JS Indtrodution
Angular JS IndtrodutionAngular JS Indtrodution
Angular JS Indtrodution
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Angular js
Angular jsAngular js
Angular js
 
Building an End-to-End AngularJS Application
Building an End-to-End AngularJS ApplicationBuilding an End-to-End AngularJS Application
Building an End-to-End AngularJS Application
 
Up and Running with ReactJS
Up and Running with ReactJSUp and Running with ReactJS
Up and Running with ReactJS
 
BDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - UdayBDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - Uday
 

Viewers also liked

Viewers also liked (6)

Реальный опыт работы с Jenkins
Реальный опыт работы с JenkinsРеальный опыт работы с Jenkins
Реальный опыт работы с Jenkins
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
 
Cross-Platform Tools: Build Once and Run Everywhere
Cross-Platform Tools: Build Once and Run EverywhereCross-Platform Tools: Build Once and Run Everywhere
Cross-Platform Tools: Build Once and Run Everywhere
 
OpenWhisk
OpenWhiskOpenWhisk
OpenWhisk
 
Geospatial Rails applications
Geospatial Rails applicationsGeospatial Rails applications
Geospatial Rails applications
 
Couchbase Performance Benchmarking 2012
Couchbase Performance Benchmarking 2012Couchbase Performance Benchmarking 2012
Couchbase Performance Benchmarking 2012
 

Similar to Angular.js опыт использования, проблемы и решения

Similar to Angular.js опыт использования, проблемы и решения (20)

Introduction of angular js
Introduction of angular jsIntroduction of angular js
Introduction of angular js
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
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
 
Introduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat MakwanaIntroduction to AngularJS By Bharat Makwana
Introduction to AngularJS By Bharat Makwana
 
Angular Js Get Started - Complete Course
Angular Js Get Started - Complete CourseAngular Js Get Started - Complete Course
Angular Js Get Started - Complete Course
 
AngularJs
AngularJsAngularJs
AngularJs
 
Learning AngularJS - Complete coverage of AngularJS features and concepts
Learning AngularJS  - Complete coverage of AngularJS features and conceptsLearning AngularJS  - Complete coverage of AngularJS features and concepts
Learning AngularJS - Complete coverage of AngularJS features and concepts
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS
AngularJSAngularJS
AngularJS
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Angular js
Angular jsAngular js
Angular js
 
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
 
Angular js - the beginning
Angular js - the beginningAngular js - the beginning
Angular js - the beginning
 
Angular - Beginner
Angular - BeginnerAngular - Beginner
Angular - Beginner
 
Angular
AngularAngular
Angular
 
Angular
AngularAngular
Angular
 
Angular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiatedAngular.js - An introduction for the unitiated
Angular.js - An introduction for the unitiated
 

More from Olga Lavrentieva

«Обзор возможностей Open cv»
«Обзор возможностей Open cv»«Обзор возможностей Open cv»
«Обзор возможностей Open cv»
Olga Lavrentieva
 

More from Olga Lavrentieva (20)

15 10-22 altoros-fact_sheet_st_v4
15 10-22 altoros-fact_sheet_st_v415 10-22 altoros-fact_sheet_st_v4
15 10-22 altoros-fact_sheet_st_v4
 
Сергей Ковалёв (Altoros): Practical Steps to Improve Apache Hive Performance
Сергей Ковалёв (Altoros): Practical Steps to Improve Apache Hive PerformanceСергей Ковалёв (Altoros): Practical Steps to Improve Apache Hive Performance
Сергей Ковалёв (Altoros): Practical Steps to Improve Apache Hive Performance
 
Андрей Козлов (Altoros): Оптимизация производительности Cassandra
Андрей Козлов (Altoros): Оптимизация производительности CassandraАндрей Козлов (Altoros): Оптимизация производительности Cassandra
Андрей Козлов (Altoros): Оптимизация производительности Cassandra
 
Владимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущееВладимир Иванов (Oracle): Java: прошлое и будущее
Владимир Иванов (Oracle): Java: прошлое и будущее
 
Brug - Web push notification
Brug  - Web push notificationBrug  - Web push notification
Brug - Web push notification
 
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
Александр Ломов: "Reactjs + Haskell + Cloud Foundry = Love"
 
Максим Жилинский: "Контейнеры: под капотом"
Максим Жилинский: "Контейнеры: под капотом"Максим Жилинский: "Контейнеры: под капотом"
Максим Жилинский: "Контейнеры: под капотом"
 
Александр Протасеня: "PayPal. Различные способы интеграции"
Александр Протасеня: "PayPal. Различные способы интеграции"Александр Протасеня: "PayPal. Различные способы интеграции"
Александр Протасеня: "PayPal. Различные способы интеграции"
 
Сергей Черничков: "Интеграция платежных систем в .Net приложения"
Сергей Черничков: "Интеграция платежных систем в .Net приложения"Сергей Черничков: "Интеграция платежных систем в .Net приложения"
Сергей Черничков: "Интеграция платежных систем в .Net приложения"
 
Антон Шемерей «Single responsibility principle в руби или почему instanceclas...
Антон Шемерей «Single responsibility principle в руби или почему instanceclas...Антон Шемерей «Single responsibility principle в руби или почему instanceclas...
Антон Шемерей «Single responsibility principle в руби или почему instanceclas...
 
Егор Воробьёв: «Ruby internals»
Егор Воробьёв: «Ruby internals»Егор Воробьёв: «Ruby internals»
Егор Воробьёв: «Ruby internals»
 
Андрей Колешко «Что не так с Rails»
Андрей Колешко «Что не так с Rails»Андрей Колешко «Что не так с Rails»
Андрей Колешко «Что не так с Rails»
 
Дмитрий Савицкий «Ruby Anti Magic Shield»
Дмитрий Савицкий «Ruby Anti Magic Shield»Дмитрий Савицкий «Ruby Anti Magic Shield»
Дмитрий Савицкий «Ruby Anti Magic Shield»
 
Сергей Алексеев «Парное программирование. Удаленно»
Сергей Алексеев «Парное программирование. Удаленно»Сергей Алексеев «Парное программирование. Удаленно»
Сергей Алексеев «Парное программирование. Удаленно»
 
«Почему Spark отнюдь не так хорош»
«Почему Spark отнюдь не так хорош»«Почему Spark отнюдь не так хорош»
«Почему Spark отнюдь не так хорош»
 
«Cassandra data modeling – моделирование данных для NoSQL СУБД Cassandra»
«Cassandra data modeling – моделирование данных для NoSQL СУБД Cassandra»«Cassandra data modeling – моделирование данных для NoSQL СУБД Cassandra»
«Cassandra data modeling – моделирование данных для NoSQL СУБД Cassandra»
 
«Практика построения высокодоступного решения на базе Cloud Foundry Paas»
«Практика построения высокодоступного решения на базе Cloud Foundry Paas»«Практика построения высокодоступного решения на базе Cloud Foundry Paas»
«Практика построения высокодоступного решения на базе Cloud Foundry Paas»
 
«Дизайн продвинутых нереляционных схем для Big Data»
«Дизайн продвинутых нереляционных схем для Big Data»«Дизайн продвинутых нереляционных схем для Big Data»
«Дизайн продвинутых нереляционных схем для Big Data»
 
«Обзор возможностей Open cv»
«Обзор возможностей Open cv»«Обзор возможностей Open cv»
«Обзор возможностей Open cv»
 
«Нужно больше шин! Eventbus based framework vertx.io»
«Нужно больше шин! Eventbus based framework vertx.io»«Нужно больше шин! Eventbus based framework vertx.io»
«Нужно больше шин! Eventbus based framework vertx.io»
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 

Angular.js опыт использования, проблемы и решения

  • 1. Vasileuski Vitali @VintJS real experience, problems & solutions https://github.com/vasvitaly/tree
  • 2. Why we started using JS framework.
  • 3. Why we started using JS framework.
  • 4. Why Angular? ● Two-way data binding ● Declarative style. Seems like HTML on steroids. ● Good collection of built-in components. ● Well testable
  • 5. Easy to start ● Tutorial for beginners ● Good enough documentation ● Big and fast-growing community.
  • 6. Important elements of powerful apps ● ng-repeat="item in collection" ● ng-include="expression" ● $resource
  • 7. Problems we faced. ● Convert data, got from server before using it. ● No if – else in Views ● Rendering trees. ● Dark side of two-way binding ● How to bind Angular to Rails app? ● Using jQuery and jQueryUI in AngularJS app
  • 8. Convert data, got from server before using it Just do it in request's callback. $scope.questions = Question.query( {screener_id:$scope.screener.id}, function(){ Some convert actions ... $scope.questions = converted_data; } );
  • 9. No if – else in Views ● ng-show | ng-hide – for simple cases ● ng-include=”expression” - for choosing what partial to render
  • 10. Rendering trees <div ng-app="treeApp"> <div ng-controller="TreeCtrl"> <script type="text/ng-template" id="node.html"> <span>{{node.name}}</span> <ul> <li ng-repeat="node in node.nodes" ng-include="'node.html'"></li> </ul> </script> <div id=”tree” class=”tree“> <ul> <li ng-repeat="node in nodes" ng-include="'node.html'"></li> </ul> </div> </div>
  • 11. Dark side of two-way binding If you want Angular to not watch your variable, just initialize it out of scope.
  • 12. How to bind Angular to Rails app? ● gem 'angularjs-rails' ● Configure $httpProvider.defaults in your app or controller app = angular.module('treeApp',["ngResource"]) .config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.headers.post['Content-Type'] = 'application/json' $httpProvider.defaults.headers.put['Content-Type'] = 'application/json' # assumes the presence of jQuery token = $("meta[name='csrf-token']").attr("content") $httpProvider.defaults.headers.post['X-CSRF-Token'] = token $httpProvider.defaults.headers.put['X-CSRF-Token'] = token $httpProvider.defaults.headers.common['X-CSRF-Token'] = token }])
  • 13. jQuery and jQueryUI with AngularJS angular.module('treeBuilder', []) .directive('tree', ['$document', function($document){ return { options: {}, scope: true, link: function(scope, elm, attrs) { moveNode = function(moved_node, lnode, rnode) { scope.moveNodeTo(opts) } $document.ready( function() { $( "#tree" ).sortable( items: "li", update: function(event, ui) { moveNode(moved_node, left_node, right_node); } ); } } } }]);
  • 14. What is in a result? ● Angular is a real friend for fast developing real WEB 3.0 applications. ● Most of problems are already solved, see docs and Google+ ● Most of problems can be solved thinking Angular way.
  • 15. С чего начать? http://angularjs.org Example Editable Tree application https://github.com/vasvitaly/tree