我有一個directive
與代碼如何從指令觸發事件的角度
seriesClick: function (e) {
//console.log(e.category);
// use scope.$emit to pass it to controller
scope.$emit('feederValue', e.category);
},
在我controller
我使用
$scope.$on('feederValue', function (evt, value) {
console.log(value);
$scope.feederFitBoundValue = value;
$scope.getFitBoundForFeederID($scope.feederFitBoundValue);
});
我想在不同的指令 我來定義這個功能想用它
我的代碼
function getFitBoundForFeederID(feederFitBoundValue){
alert(feederFitBoundValue);
}
我收到錯誤TypeError: undefined is not a function
我的項目是在Angular
框架我想使用的$emit
和$on
邏輯請建議,如果任何的Optimus解決方案。我只是想將One指令的值傳遞給不同的指令。同時我想從一個指令傳遞一些值到另一個指令。我想要做事件觸發。