Skip to content
Browse files

- figured out how to apply classes conditionally

- edit on doubleclick
  • Loading branch information...
1 parent 55f09a2 commit 500a7d48ed27a5d03b9769cbe063527b1ea874c6 @cburgdorf cburgdorf committed Feb 29, 2012
Showing with 12 additions and 1 deletion.
  1. +1 −1 architecture-examples/angularjs/index_new.html
  2. +11 −0 architecture-examples/angularjs/js/directive.js
View
2 architecture-examples/angularjs/index_new.html
@@ -21,7 +21,7 @@
<input id="toggle-all" type="checkbox">
<label for="toggle-all">Mark all as complete</label>
<ul id="todo-list">
- <li ng:repeat="todo in todos" ng:click="editTodo(todo)" ng:class="'editing-' + todo.editing + ' done-' + todo.done">
+ <li ng:repeat="todo in todos" my:dblclick="editTodo(todo)" ng:class="(todo.done && ' done ') + (todo.editing && ' editing ')">
<div class="view">
<input class="toggle" type="checkbox" name="todo.done">
<label>{{ todo.content }}</label>
View
11 architecture-examples/angularjs/js/directive.js
@@ -10,6 +10,17 @@ angular.directive('my:blur', function(expression, compiledElement) {
};
});
+angular.directive('my:dblclick', function(expression, compiledElement) {
+ var compiler = this;
+ return function(linkElement) {
+ var scope = this;
+ linkElement.bind('dblclick', function(event) {
+ scope.$apply(expression, linkElement);
+ event.stopPropagation();
+ });
+ };
+});
+
angular.directive("my:focus", function(expression, compiledElement){
return function(element){
this.$watch(expression, function(){

0 comments on commit 500a7d4

Please sign in to comment.
Something went wrong with that request. Please try again.