CoffeeScript - Referencing DOM nodes in Angular expressions is disallowed

前端 未结 3 764
礼貌的吻别
礼貌的吻别 2021-02-05 00:19

My main question is simple :

I get errors when doing DOM manipulation within Controllers or Directives however, the functionality works perfectly.

Erro         


        
3条回答
  •  轮回少年
    2021-02-05 01:01

    As the error states, Angular disallows accessing DOM nodes in expressions.

    CoffeeScript uses an implicit return if none is specified.

    This means that for example the scope.open function in your code will:

    return element.dialog('open');
    

    Angular will detect this and throw the error.

    If you add an explicit return it should solve the issue:

    scope.open = =>
      element.dialog('open') 
      return true
    

提交回复
热议问题