angular.js - angular指令通過"="不能獲取數(shù)據(jù)
問題描述
也不能說(shuō)不能獲取,但是不知道出了什么問題, 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));//這樣應(yīng)該能取得的。 console.log('---------directive---------');}
因?yàn)閿?shù)據(jù)的異步問題
回答2:你這個(gè)數(shù)據(jù)是從后臺(tái)獲取的吧。使用$watch監(jiān)聽一下,你就知道了,我也認(rèn)為是異步的問題。
相關(guān)文章:
1. boot2docker無(wú)法啟動(dòng)2. 關(guān)于docker下的nginx壓力測(cè)試3. java - SSH框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類4. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.5. mac里的docker如何命令行開啟呢?6. node.js - antdesign怎么集合react-redux對(duì)input控件進(jìn)行初始化賦值7. 為什么我ping不通我的docker容器呢???8. 老師,按tab鍵不起作用怎么回事9. docker鏡像push報(bào)錯(cuò)10. dockerfile - 為什么docker容器啟動(dòng)不了?

網(wǎng)公網(wǎng)安備