angular.js - angular指令通过"="不能获取数据
習慣沉默
習慣沉默 2017-05-15 16:56:37
0
2
559

也不能说不能获取,但是不知道出了什么问题, 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---------");
}

習慣沉默
習慣沉默

reply all(2)
过去多啦不再A梦
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---------");
}

Because of the asynchronous problem of data

黄舟

Is this data obtained from the background?
Use $watch to monitor and you will know. I also think it is an asynchronous problem.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template