Watch for element visibility change in angulardart

Issue

I have the same exact question that has already been posted for angularjs (Angular – Watch for ngShow/ngHide Changes in Ancestors that Affect Child DOM Element's Visibility) except in my case we are using angulardart. I cannot seem to watch a function in angulardart. When I try to, I get an error from the expression parser stating that “{” is unexpected. Is there a better way to do this in angulardart? If not, how can I watch a function similar to angularjs?

I’ve tried the following code with no success:

scope.watch("() { return _element.hidden; }", (value, _) {
        print(value);
});

Parser Error: Unexpected token ) at column 2 in [() { return _element.hidden; }]

scope.watch("(scope) { return _element.hidden; }", (value, _) {
        print(value);
});

Parser Error: ‘{‘ is an unexpected token at column 9 in [(scope) { return _element.hidden; }]

We are using angular.dart 1.1.2

Solution

You could use MutationObserver, it notifies about DOM changes. See for example In Dart why the code below (about MutationObserver) dose not work? (there should be more examples on SO)

Answered By – Günter Zöchbauer

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *