Skip to content

Commit 4d05f3c

Browse files
committed
wip ng-pseudo
1 parent 2fcc3ab commit 4d05f3c

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

demo/todo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h2>Things To Do ;-)</h2>
2424
<ul class="well unstyled">
2525
<li ng-repeat="item in todo.items" ng-class="todo.classFor(item)">
2626
<label class="checkbox">
27-
<input type="checkbox" ng-model="item.done"> {{item.text}}
27+
<input type="checkbox" ng-model="item.done"> {{item.text}} <todo-type symbol="?"></todo-type>
2828
</label>
2929
</li>
3030
</ul>

demo/todo/main.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ main() {
1010
print(window.location.search);
1111
var module = new Module()
1212
..type(TodoController)
13+
..type(NgPseudo)
14+
..type(TypeComponent)
1315
..type(PlaybackHttpBackendConfig);
1416

1517
// If these is a query in the URL, use the server-backed

demo/todo/todo.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ p {
4747
padding-top: 10px;
4848
padding-bottom: 10px;
4949
}
50+
51+
li:hover todo-type::x-text {
52+
font-weight: bold;
53+
}

demo/todo/todo.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
library todo;
22

33
import 'package:angular/angular.dart';
4+
import 'dart:html' as dom;
45

56
class Item {
67
String text;
@@ -91,3 +92,39 @@ class TodoController {
9192
return items.where((item) => !item.done).length;
9293
}
9394
}
95+
96+
@NgDirective(
97+
selector: '[ng-pseudo]',
98+
map: const { 'ng-pseudo': '@name' }
99+
)
100+
class NgPseudo {
101+
dom.Element _elt;
102+
set name(n) {
103+
_elt.pseudo = n;
104+
}
105+
106+
NgPseudo(dom.Element this._elt);
107+
}
108+
109+
110+
@NgComponent(
111+
selector: 'todo-type',
112+
map: const {
113+
'symbol': '@symbol'
114+
},
115+
template: """<span style=\'border:1px solid black; padding: 0.1em\'>
116+
[<span ng-bind="ctrl.symbol" ng-pseudo="x-text" ng-click="ctrl.rotSymbol()"></span>]
117+
</span>""",
118+
publishAs: 'ctrl'
119+
)
120+
class TypeComponent {
121+
String symbol;
122+
rotSymbol() {
123+
switch (symbol) {
124+
case '?': return symbol = '!';
125+
case '!': return symbol = '#';
126+
case '#': return symbol = '*';
127+
case '*': return symbol = '?';
128+
}
129+
}
130+
}

0 commit comments

Comments
 (0)