为什么你不能从另一个 Controller 中访问其他 Controller 方法?
像这样。
module.exports =
findStore: ->
# do somthing
index: ->
@findStore(); # Error: undefined
编译
module.exports = {
findStore: function() {},
index: function() {
return this.findStore(); // Error: undefined
}
};
如果你不能这样做,那为什么不呢?我应该怎么做...
最佳答案
您可以使用 sails.controllers.yourControllerName.findStore()
sails
全局对象几乎可以引用所有内容。
关于javascript - sails.js 从 Controller 方法访问 Controller 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20735380/