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

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

问题描述

我想在移除dart-angular控制器时调用destroy函数。



这是angular.js解决方案。

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

我在Dart尝试

 code $ test $ {

} $ {



$ b ){
print(destroy);
});
}

这是错误代码

 错误! 
NoSuchMethodError:method not found:'destroy'

$ destroy或者destroy 文字不工作。任何想法?

解决方案

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



< =lang-dart prettyprint-override> 类TestConroller实现NgDetachAware {
void detach(){
alert(destroy);
}
}


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?

解决方案

I think this is a better way

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

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

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