在我的模板中,我调用目录:
<div ng-controller="ProfileController as vm">
{{vm.profile._id}} <!-- test ok! _id printing -->
<wcr-requestbutton receiving-id="vm.profile._id"></wcr-requestbutton>
</div>
在我的目录中,我搜索receive-id:
function wcrRequestbutton() {
var directive = {
restrict: 'E',
templateUrl: 'app/components/friendship/requestbutton/requestbutton.html',
scope: {
receivingId: '='
},
controller: requestBtnCtrl,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
在我的控制器中,我尝试使用receiverId varaible:
function requestBtnCtrl(friendshipService){
var vm=this;
console.log('vm: ',vm); // console print: 'vm: Object { receivingId: undefined }'
}
但是当我启动demo时,我的控制台打印出这个结果: vm:Object {receivingId:undefined}
为什么呢?可以帮帮我吗?