<input type="range">
git clone
https://github.com/marcin-wosinek/workshop-2.gitgit config --global alias.tree "log --oneline --graph --decorate --all"
<!-- Add your site or application content here -->
<div class="container" ng-view></div>
<script src="components/angular/angular.js"></script>
<script src="components/underscore/underscore.js"></script>
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/contact/:id', {
redirectTo: '/contact/:id/view'
})
angular.module('workshop2App')
.controller('ContactViewCtrl',
function ($scope, $routeParams, contacts) {
$scope.contact = contacts.get($routeParams.id);
$scope.id = $routeParams.id;
});
angular.module('workshop2App')
.factory('contacts', function () {
var exampleContacts = [ ... ];
// Public API here
return {
getAll: function () {
return exampleContacts;
},
get: function (id) {}
var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
// => [2, 4, 6]
var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
// => 6
_.isString(object)
_.isNumber(object)
git checkout slide-1
<p></p>
<p>Output: </p>
<tr ng-repeat="friend in friends | filter:searchText">
</tr>
angular.module('workshop2App')
.filter('filterName', function () {
return function (input, arg1, arg2) {
return 'between filter: ' + input;
};
});
<li ng-repeat="element in list | filterName:value1:value2">
var array = [1, 2, 3];
angular.forEach(array, function(value){
this.push('Value: ' + value);
});
git checkout todo-1
<tr ng-repeat="contact in contacts | between:'age':min:max">
git add .
git commit -m '(commit message)'
git checkout done-1
return function (input, key, min, max) {
if (angular.isArray(input)) {
var toReturn = [];
angular.forEach(input, function (element) {
if (min <= element[key] && element[key] <= max) {
toReturn.push(element);
}
});
return toReturn;
}
// is not array - just return unmodified and forget
return input;
};
git checkout todo-2
git add .
git commit -m '(commit message)'
git checkout done-2
<li ng-animate="'animate'" ng-repeat="contact in contacts | between:'age':min:max">
.animate-enter,
.animate-leave
{
-webkit-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
-moz-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
-ms-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
-o-transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
transition: 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;
position: relative;
display: block;
overflow: hidden;
text-overflow: clip;
white-space:nowrap;
}
git checkout slide-3
<!-- Before -->
<div class="container" ng-view></div>
<!-- After -->
<div ng-controller="GlobalCtrl">
<div class="container" ng-view></div>
</div>
git checkout slide-4
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g,
function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);});
git checkout todo-3
git add .
git commit -m '(commit message)'
git checkout done-3
angular.module('workshop2App')
.controller('GlobalCtrl', function ($scope, $cookies, wsUuidGenerator) {
// if it's empty set trackingId on cookie to new created UUID
if (!angular.isString($cookies.trackingId)) {
$cookies.trackingId = wsUuidGenerator.createUuid();
}
});
<span my-dir="exp"></span>
<span class="my-dir: exp;"></span>
<my-dir></my-dir>
<!-- directive: my-dir exp -->
git checkout slide-5
angular.module('workshop2App')
.directive('wsAcceptCookies', function () {
return {
template: '<div></div>',
restrict: 'E',
link: function postLink(scope, element, attrs) {
element.text('this is the wsAcceptCookies directive');
}
};
});
{
transclude: true,
template: '<div ng-transclude></div>'
}
git checkout todo-4
git add .
git commit -m '(commit message)'
git checkout done-4
return {
template: '<div ng-transclude></div>' +
'<button>Akceptuje</button>',
restrict: 'A',
transclude: true,
link: function postLink(scope, element, attrs) {
}
git checkout todo-5
git add .
git commit -m '(commit message)'
git checkout done-5
link: function postLink(scope, element, attrs) {
// accept button logic
scope.accept = function () {
$cookies.accepted = 'true';
element.css('display', 'none');
};
// hide element if cookies are already accepted
if ($cookies.accepted) {
element.css('display', 'none');
}
}