I have a controller that defines:
- some properties that control how my ui looks like
- a method that may be called to change these properties
I also have a directive that receives the controller's method as a parameter to be able to call it.
After angular.dart v0.9.9. any change in the controller's properties is not detected anymore. Since I use scope only implicitly, through the controller's properties, I am not sure if/how I should use 'scope.context', mentioned in the 'breaking changes' section of angular.dart 0.9.9.
How can I fix this?
[update]
Below is some code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>test</title>
</head>
<body ng-cloak ng-controller="app-ctrl">
<div>selections: {{ ctrl.selections }}</div>
<div class="test-click" whenclicked="ctrl.goRight()">click</div>
<script type="application/dart" src="/test/web/main.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>
main.dart
library test;
import 'package:angular/angular.dart';
import '../lib/src/app_ctrl.dart';
import '../lib/src/click_dir.dart';
void main() {
ngBootstrap(module: new TestModule());
}
class TestModule extends Module {
TestModule() {
type(AppCtrl);
type(TestClickDir);
}
}
app_ctrl.dart
library app;
import 'package:angular/angular.dart';
/** AppCtrl */
@NgController(selector: '[ng-controller=app-ctrl]', publishAs: 'ctrl')
class AppCtrl {
List selections;
AppCtrl() {
selections = ['a','a'];
}
void goRight() {
selections.add('a');
}
}
click_dir.dart
library clickable;
import 'package:angular/angular.dart';
import 'dart:html';
/** TestClickDir */
@NgDirective(selector: '.test-click', map: const {
'whenclicked': '&click'
})
class TestClickDir implements NgAttachAware {
Function click;
Element self;
TestClickDir(Element el) {
self = el;
}
void attach() {
self.onClick.listen((e) => click());
}
}