【发布时间】:2014-04-09 23:35:05
【问题描述】:
这与堆栈上的其他问题略有不同,我需要使用仅存在于我的指令中的参数来调用控制器的函数。
指令(标记):
<div do-something="doSomething(x)"></div>
指令(js):
var directive = function () {
return {
restrict: 'EA',
templateUrl: '/angular/node-for-detail.html',
scope: {
doSomething: '&'
}
}
};
指令内的标记:
<span ng-click="doSomething('im not resolving')"></span>
控制器内部的功能:
$scope.doSomething = function(myVar) { //myVar is null };
所以问题是,在指令 param.abs 内部解决得很好,但是在被调用的作用域函数内部,参数为空!我究竟做错了什么?如何获取参数以使其通过?
【问题讨论】:
标签: javascript angularjs angularjs-directive