Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 views
in Technique[技术] by (71.8m points)

angular.js 如何接收后台传递过来的数据

在TP的项目中遇到一个问题,前端页面是用angular.js实现的一个列表,我先把后台的json数组传递到页面:
//ag配置信息
var ag_data = {};
ag_data.address = '{$address}';
ag_data.url = "{:U('')}";
console.log(ag_data.url);
然后页面底部 引用了一个js文件,里面是angular.js写的一个逻辑,我把页面中传递的url到js文件中,可以获取,但是到controller中就无法获取图片描述

浏览器打印出的错误是这样的图片描述

如何才能把外面的值传递到angular的作用域中。。。
本人菜鸟,请大神们指导一下╮(╯▽╰)╭


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

https://docs.angularjs.org/er...$injector/unpr?p0=$applyProvider%20%3C-%20$apply%20%3C-%20localCon
我怀疑是你的localCon 控制器有问题

clipboard.png

你把controller换成这样的写法试试

angular.module('myApp', [])
.controller('MyController', ['myService', function (myService) {
  // Do something with myService
}]);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...