Angular Dart $scope.$on 功能不起作用 [英] Angular Dart $scope.$on functionality is not working

查看:26
本文介绍了Angular Dart $scope.$on 功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当 dart-angular 控制器被移除时,我想调用一个销毁函数.

I want to call a destroy function when the dart-angular controller are removed.

这是 angular.js 的解决方案.

This is the angular.js solution.

$scope.$on("$destroy", function() {
       alert("destroy");
});

我在 Dart 中的尝试

My try in Dart

class TestController...

TestController(Scope $scope){
    $scope.$on("$destroy",(){
            print("destroy");
    });
}

这是错误代码

Error!
NoSuchMethodError : method not found: 'destroy'

$destroy or destroy 文字不起作用.有什么想法吗?

$destroy or destroy literal is not working. Any Idea?

推荐答案

我认为这是一个更好的方法

I think this is a better way

class TestConroller implements NgDetachAware {
  void detach() {
    alert("destroy");
  }
}

这篇关于Angular Dart $scope.$on 功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆