问题
I want to call a destroy function when the dart-angular controller are removed.
This is the angular.js solution.
$scope.$on("$destroy", function() {
alert("destroy");
});
My try in Dart
class TestController...
TestController(Scope $scope){
$scope.$on("$destroy",(){
print("destroy");
});
}
and this is the Error Code
Error!
NoSuchMethodError : method not found: 'destroy'
$destroy or destroy
literal is not working. Any Idea?
回答1:
I think this is a better way
class TestConroller implements NgDetachAware {
void detach() {
alert("destroy");
}
}
回答2:
The first parameter of $on
must be a pattern.
You must declare it using the r
prefix.
$scope.$on(r'$destroy', function() {
alert("destroy");
});
来源:https://stackoverflow.com/questions/21403654/angular-dart-scope-on-functionality-is-not-working