我如何获取/复制/访问从Angular的Rails数组?我在我的def new
函数中有一个名为@array_of_names
的字符串数组,并且想要在我的Angular函数中使用相同的数组(@array_of_names
)。有什么办法做到这一点,所以我可以在我的Angular方面有@array_of_names?我如何获取/复制/访问从角度的Rails数组
Rails的文件
def new
@account = Account.new
@array_of_names = read_names()
end
角文件
(() => {
angular
.module('accounts')
.controller('AccountsController', AccountsController)
AccountsController.$inject = []
//testing function
function AccountsController() {
let vm = this;
vm.claim = "Hello, world!";
}
})()
使用'工作的链接$ http'做出ajax请求,并有轨道发送json响应 – charlietfl
@charlietfl,我只是最近才开始使用rails,这是我第一天的Angular经验....你能澄清一下你意思? – user6465508
https://docs.angularjs.org/api/ng/service/$http – charlietfl