调用此angularjs中定义的函数

时间:2016-03-15 16:52:50

标签: javascript angularjs angularjs-scope

我有一个函数定义了这个以在模型中调用但是如何在控制器中调用该函数? Angular生成错误

  

TypeError:这是未定义的

示例代码

this.addForms = function addForms (param1, param2) {
    //function code
}

function auxFunction () {
  this.addForms (0 , 1);
}

1 个答案:

答案 0 :(得分:0)

this.addForms = function addForms (param1, param2) {
    //function code
}

var self = this;  //i.e just answered by @Nephelococcygia 

function auxFunction () {
  self.addForms (0 , 1);
}