Christopher Bloom
Frontend developer, lover of design systems, CSS architecture, and all things javascript.
Christopher Bloom, Phase2
Portland Drupal Frontend Users Group
"Bloom wants to try all the teas in the tea shop below the Phase2 office but he can't remember which ones he tried. Let's make a grid of teas he can take notes on."
$(document).ready(function(){
$('#some-element').click(function(e){
e.preventDefault();
//some interaction
});
});
$(document).ready(function() {
$('#some-element').click(function(e){
$.get('/api/list-comments', function(data) {
var $comments = $('<div></div>');
$comments.addClass('comment-list');
for(comment in data.comments) {
var $comment = $('<div></div>');
$comment.addClass('comment');
var $link = $('<a></a>');
$link.attr('href', comment.userUrl);
$link.addClass('user');
$comment.append($link);
var $content = $('<div></div>');
$content.addClass('comment-content');
$content.html(comment.content);
}
$('.comment-list').html('');
$('.comment-list').append($comments);
});
e.preventDefault();
});
});
app.controller('mainCtrl', ['$scope', '$http',
function($scope, $http) {
$scope.getRepos = function() {
$http.get('https://api.github.com/users/illepic/repos').success(
function(data) {
$scope.repos = data;
}
);
};
}
]);
<div ng-controller="mainCtrl">
<button ng-click="getRepos()" id="some-element">Get repos</button>
<div class="comments">
<div ng-repeat="repo in repos" class="comment">
<a href="{{repo.url}}" class="user">{{repo.owner.login}}</a>
<div class="comment-content">{{repo.name}}</div>
</div>
</div>
</div>
JS
HTML
"In jQuery, you design a page, and then you make it dynamic. This is because jQuery was designed for augmentation and has grown incredibly from that simple premise."
"But in AngularJS, you must start from the ground up with your architecture in mind. Instead of starting by thinking "I have this piece of the DOM and I want to make it do X", you have to start with what you want to accomplish, then go about designing your application, and then finally go about designing your view."
Headless Drupal feeding data to Angular!
http://dev-headless-drupal-8.gotpantheon.com/headless/angular/index.html
By Christopher Bloom
Let's build a small Angular.js app.
Frontend developer, lover of design systems, CSS architecture, and all things javascript.