angular.js - angular指令通过"="不能获取数据
问题描述
也不能说不能获取,但是不知道出了什么问题, scope 可以看到, 但是通过属性访问却访问不到
具体看下面代码和图片
html 中
<ul widget-paginate='vm.activities'></ul>
directive.js 中
var directive = { scope:{paginate : ’=widgetPaginate’ }, link : link}function link(scope, ele, attrs){ console.log(scope); console.log('---------directive---------'); console.log(scope.paginate.data); console.log('---------directive---------');}



问题解答
回答1:var directive = { scope:{paginate : ’=widgetPaginate’ }, link : link}function link(scope, ele, attrs){ console.log(scope); console.log('---------directive---------'); $timeout(console.log(scope.paginate.data));//这样应该能取得的。 console.log('---------directive---------');}
因为数据的异步问题
回答2:你这个数据是从后台获取的吧。使用$watch监听一下,你就知道了,我也认为是异步的问题。
相关文章:
1. Mysql取下一条记录2. mysql federated引擎无法开启3. 求助一个Android控件名称4. Chrome-org.openqa.selenium.WebDriverException:未知错误:无法在driver.manage()window()maximize();处获得自动化扩展5. javascript 如何下载一个excel文件 ?6. notepad+编写的html,打开就是这样了。为什么,大神们7. python对8000行csv添加列8. python 如何打印bytes以16进制输出9. javascript - vue-resource 如何二次封装10. sublime text 3不支持python的input吗

网公网安备