Skip to content

Commit 500a7d4

Browse files
committed
- figured out how to apply classes conditionally
- edit on doubleclick
1 parent 55f09a2 commit 500a7d4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

architecture-examples/angularjs/index_new.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1>Todos</h1>
2121
<input id="toggle-all" type="checkbox">
2222
<label for="toggle-all">Mark all as complete</label>
2323
<ul id="todo-list">
24-
<li ng:repeat="todo in todos" ng:click="editTodo(todo)" ng:class="'editing-' + todo.editing + ' done-' + todo.done">
24+
<li ng:repeat="todo in todos" my:dblclick="editTodo(todo)" ng:class="(todo.done && ' done ') + (todo.editing && ' editing ')">
2525
<div class="view">
2626
<input class="toggle" type="checkbox" name="todo.done">
2727
<label>{{ todo.content }}</label>

architecture-examples/angularjs/js/directive.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ angular.directive('my:blur', function(expression, compiledElement) {
1010
};
1111
});
1212

13+
angular.directive('my:dblclick', function(expression, compiledElement) {
14+
var compiler = this;
15+
return function(linkElement) {
16+
var scope = this;
17+
linkElement.bind('dblclick', function(event) {
18+
scope.$apply(expression, linkElement);
19+
event.stopPropagation();
20+
});
21+
};
22+
});
23+
1324
angular.directive("my:focus", function(expression, compiledElement){
1425
return function(element){
1526
this.$watch(expression, function(){

0 commit comments

Comments
 (0)