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. python - django 里自定義的 login 方法,如何使用 login_required()2. android-studio - Android 動態壁紙LayoutParams問題3. sql語句如何按or排序取出記錄4. angular.js - 不適用其他構建工具,怎么搭建angular1項目5. 主從備份 - 跪求mysql 高可用主從方案6. python如何不改動文件的情況下修改文件的 修改日期7. mysql優化 - mysql count(id)查詢速度如何優化?8. css3 - [CSS] 動畫效果 3D翻轉bug9. mysql主從 - 請教下mysql 主動-被動模式的雙主配置 和 主從配置在應用上有什么區別?10. node.js - node_moduls太多了
