Skip to content

Commit

Permalink
wip ng-pseudo
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdeboer committed Jan 8, 2014
1 parent 2fcc3ab commit 4d05f3c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion demo/todo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h2>Things To Do ;-)</h2>
<ul class="well unstyled">
<li ng-repeat="item in todo.items" ng-class="todo.classFor(item)">
<label class="checkbox">
<input type="checkbox" ng-model="item.done"> {{item.text}}
<input type="checkbox" ng-model="item.done"> {{item.text}} <todo-type symbol="?"></todo-type>
</label>
</li>
</ul>
Expand Down
2 changes: 2 additions & 0 deletions demo/todo/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ main() {
print(window.location.search);
var module = new Module()
..type(TodoController)
..type(NgPseudo)
..type(TypeComponent)
..type(PlaybackHttpBackendConfig);

// If these is a query in the URL, use the server-backed
Expand Down
4 changes: 4 additions & 0 deletions demo/todo/todo.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ p {
padding-top: 10px;
padding-bottom: 10px;
}

li:hover todo-type::x-text {
font-weight: bold;
}
37 changes: 37 additions & 0 deletions demo/todo/todo.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library todo;

import 'package:angular/angular.dart';
import 'dart:html' as dom;

class Item {
String text;
Expand Down Expand Up @@ -91,3 +92,39 @@ class TodoController {
return items.where((item) => !item.done).length;
}
}

@NgDirective(
selector: '[ng-pseudo]',
map: const { 'ng-pseudo': '@name' }
)
class NgPseudo {
dom.Element _elt;
set name(n) {
_elt.pseudo = n;
}

NgPseudo(dom.Element this._elt);
}


@NgComponent(
selector: 'todo-type',
map: const {
'symbol': '@symbol'
},
template: """<span style=\'border:1px solid black; padding: 0.1em\'>
[<span ng-bind="ctrl.symbol" ng-pseudo="x-text" ng-click="ctrl.rotSymbol()"></span>]
</span>""",
publishAs: 'ctrl'
)
class TypeComponent {
String symbol;
rotSymbol() {
switch (symbol) {
case '?': return symbol = '!';
case '!': return symbol = '#';
case '#': return symbol = '*';
case '*': return symbol = '?';
}
}
}

0 comments on commit 4d05f3c

Please sign in to comment.